AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.48k stars 2.31k forks source link

Error ValueError: You are trying to merge on object and datetime64[ns, America/New_York] columns. in processor_yahoofinance.py #986

Open joshwigginton opened 1 year ago

joshwigginton commented 1 year ago

Describe the bug

Error in processor_yahoofinance.py, def add_technical_indicator

ValueError: You are trying to merge on object and datetime64[ns, America/New_York] columns. If you wish to proceed you should use pd.concat

File "/workspace/FinRL/finrl/train.py", line 110, in train( File "/workspace/FinRL/finrl/train.py", line 33, in train data = dp.add_technical_indicator(data, technical_indicator_list) File "/home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/finrl/meta/data_processor.py", line 52, in add_technical_indicator df = self.processor.add_technical_indicator(df, tech_indicator_list) File "/home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/finrl/meta/data_processors/processor_yahoofinance.py", line 253, in add_technical_indicator df = df.merge( File "/home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/pandas/core/frame.py", line 10093, in merge return merge( File "/home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 110, in merge op = _MergeOperation( File "/home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 707, in init self._maybe_coerce_merge_keys() File "/home/user/anaconda3/envs/FinRL/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 1346, in _maybe_coerce_merge_keys raise ValueError(msg) ValueError: You are trying to merge on object and datetime64[ns, America/New_York] columns. If you wish to proceed you should use pd.concat

To Reproduce Steps to reproduce the behavior:

  1. Run main.py or train.py from finrl folder. After the data is downloaded, error in data processor, adding indicators.

Expected behavior main or train.py to run without error.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

zhumingpassional commented 1 year ago

pls use pd.concat

grantchiu011101 commented 5 months ago

seem the problem exists, the root cause is df.timestamp and indicator.timestamp object type is not match.

https://github.com/AI4Finance-Foundation/FinRL/blob/3393f62e65248a15f1ff5a289c2ed82860fc30fb/finrl/meta/data_processors/processor_yahoofinance.py#L256