Open olistokes opened 5 months ago
instead of append you can use `df_trade_date = pd.DataFrame({'datadate': unique_trade_date}) df_account_value = pd.DataFrame()
for i in range(rebalance_window + validation_window, len(unique_trade_date) + 1, rebalance_window): temp = pd.read_csv('results/account_valuetrade{}_{}.csv'.format('ensemble', i)) df_account_value = pd.concat([df_account_value, temp], ignore_index=True)
sharpe = (252*0.5) df_account_value['account_value'].pct_change(1).mean() / df_account_value['account_value'].pct_change(1).std() print('Sharpe Ratio: ', sharpe)
df_account_value = pd.concat([df_account_value, df_trade_date[validation_window:].reset_index(drop=True)], axis=1)`
use concat
helpful!
I get the following attribution error:
AttributeError Traceback (most recent call last) in <cell line: 4>()
4 for i in range(rebalance_window+validation_window, len(unique_trade_date)+1,rebalance_window):
5 temp = pd.read_csv('results/account_valuetrade{}_{}.csv'.format('ensemble',i))
----> 6 df_account_value = df_account_value.append(temp,ignore_index=True)
7 sharpe=(252*0.5)df_account_value.account_value.pct_change(1).mean()/df_account_value.account_value.pct_change(1).std()
8 print('Sharpe Ratio: ',sharpe)
/usr/local/lib/python3.10/site-packages/pandas/core/generic.py in getattr(self, name) 6291 ): 6292 return self[name] -> 6293 return object.getattribute(self, name) 6294 6295 @final
AttributeError: 'DataFrame' object has no attribute 'append'
Desktop (please complete the following information):