我使用timeseries
创建了一些pandas
,我想计算以下内容:
ts = NAV.objects.get_adj_nav(fund_id)['adj_nav']
ts.name = Fund.objects.get(id=fund_id).account_class_description
ts = ts.to_frame()
cols_to_datetime(ts,'index')
ts_df = ffn.core.calc_stats(ts).to_csv(sep=',')
print(ts_df)
所以这只是循环的一次迭代,而ts_df
产生这样的东西:
Stat,CLASS F
Start,2013-09-03
End,2017-08-18
Risk-free rate,0.00%
,,,,,,,,,,,
Total Return,50.27%
Daily Sharpe,1.13
Daily Sortino,1.54
CAGR,10.84%
Max Drawdown,-11.06%
Calmar Ratio,0.98
因此,对于每个timeseries
,这将使用不同的values
生成,但标签(例如“第一列”)将是相同的。所以我只是想知道如何将不同的ts_df
组合成一个大的csv
对象?
编辑:例如,输出将是这样的:
Stat,CLASS F, CLASS G
Start,2013-09-03, 2013-09-07
End,2017-08-18, 2017-08-28
Risk-free rate,0.00%, 0.01%
,,,,,,,,,,,
Total Return,50.27%, 51.27%
Daily Sharpe,1.13, 1.16
Daily Sortino,1.54, 1.77
CAGR,10.84%, 11.7%
Max Drawdown,-11.06%, -9.7%
Calmar Ratio,0.98, 0.88