enzoampil / fastquant

fastquant — Backtest and optimize your ML trading strategies with only 3 lines of code!
MIT License
1.51k stars 236 forks source link

[BUG] cannot import name 'json_normalize' from 'pandas.io.json' #432

Open ghabxph opened 2 months ago

ghabxph commented 2 months ago

Problem description

Just followed the snippet from the main page

Example

from fastquant import get_crypto_data
crypto = get_crypto_data("BTC/USDT", "2022-01-01", "2024-07-14")
crypto.head()

Expected behavior

I should see market data like this:

#             open    high     low     close    volume
# dt                                                          
# 2018-12-01  4041.27  4299.99  3963.01  4190.02  44840.073481
# 2018-12-02  4190.98  4312.99  4103.04  4161.01  38912.154790
# 2018-12-03  4160.55  4179.00  3827.00  3884.01  49094.369163
# 2018-12-04  3884.76  4085.00  3781.00  3951.64  48489.551613
# 2018-12-05  3950.98  3970.00  3745.00  3769.84  44004.799448

Actual behavior

image

Environment

wyt3721 commented 2 months ago

maybe u can revise 'from pandas.io.json import json_normalize ' to 'from pandas.io.json import _normalize' . I check pandas.io.json and only find _normalize.py , there is no json_normalize.py . in fact ,pandas.io.json.json_normalize is deprecated after pandas 1.0.0, use pandas.json_normalize instead.

feree999 commented 1 month ago

I had the exact same error. I'm a very novice programmer so I tried a very simple (and may not the best) solution but it worked: I duplicated and renamed the _normalize file to json_normalize in the ...\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\io\json folder. This way I have both _normalize and json_normalize. If you have a more professional fix please share!