Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

China_A_share_market_tushare AttributeError #283

Open
zhilee2023 opened this issue Mar 28, 2023 · 4 comments
Open

China_A_share_market_tushare AttributeError #283

zhilee2023 opened this issue Mar 28, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@zhilee2023
Copy link

When I run China_A_share_market_tushare.ipynb, the following error came accross. It seems the dataframe has no attribute date.


AttributeError Traceback (most recent call last)
Cell In[42], line 3
1 env_kwargs = { "stock_dim": stock_dimension, "hmax": 1000, "initial_amount": 1000000, "buy_cost_pct": 6.87e-5, "sell_cost_pct": 1.0687e-3, "reward_scaling": 1e-4, "state_space": state_space, "action_space": stock_dimension, "tech_indicator_list": config.INDICATORS, "print_verbosity": 1, "initial_buy": True, "hundred_each_trade": True }
----> 3 e_train_gym = StockTradingEnv(df=train, **env_kwargs)

File F:\FinRL-Tutorials\1-Introduction\meta\env_stock_trading\env_stocktrading_China_A_shares.py:82, in StockTradingEnv.init(self, df, stock_dim, hmax, initial_amount, buy_cost_pct, sell_cost_pct, reward_scaling, state_space, action_space, tech_indicator_list, turbulence_threshold, make_plots, print_verbosity, day, initial, previous_state, model_name, mode, iteration, initial_buy, hundred_each_trade)
80 self.rewards_memory = []
81 self.actions_memory = []
---> 82 self.date_memory = [self._get_date()]
83 self._seed()

File F:\FinRL-Tutorials\1-Introduction\meta\env_stock_trading\env_stocktrading_China_A_shares.py:451, in StockTradingEnv._get_date(self)
449 def _get_date(self):
450 if len(self.df.tic.unique()) > 1:
--> 451 date = self.data.date.unique()[0]
452 else:
453 date = self.data.date

File D:\Anaconda\envs\stock\lib\site-packages\pandas\core\generic.py:5902, in NDFrame.getattr(self, name)
5895 if (
5896 name not in self._internal_names_set
5897 and name not in self._metadata
5898 and name not in self._accessors
5899 and self._info_axis._can_hold_identifiers_and_holds_name(name)
5900 ):
5901 return self[name]
-> 5902 return object.getattribute(self, name)

AttributeError: 'DataFrame' object has no attribute 'date'

@YangletLiu YangletLiu added the bug Something isn't working label Mar 29, 2023
@chalengr
Copy link

I want to ask this question too, do you find the answer?

@chalengr
Copy link

chalengr commented Apr 20, 2023

Could you please send me the changed code , my email is [email protected], thank you.

@huijian222
Copy link

just rename the col name works
train = train.rename(columns={'time': 'date'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants