FinRL icon indicating copy to clipboard operation
FinRL copied to clipboard

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

Open joshwigginton opened this issue 2 years ago • 2 comments

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):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

joshwigginton avatar Apr 19 '23 04:04 joshwigginton

pls use pd.concat

zhumingpassional avatar May 02 '23 01:05 zhumingpassional

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

grantchiu011101 avatar Feb 09 '24 09:02 grantchiu011101