FinRL icon indicating copy to clipboard operation
FinRL copied to clipboard

Attribute Error

Open olistokes opened this issue 1 year ago • 2 comments

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_value_trade_{}_{}.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):

  • OS: Windows 10
  • Browser: bing

olistokes avatar Jan 24 '24 21:01 olistokes

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_value_trade_{}_{}.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

krishdotn1 avatar Jan 29 '24 06:01 krishdotn1

helpful!

mrkangwon avatar Apr 29 '24 03:04 mrkangwon