简体   繁体   中英

I am getting “module 'pandas' has no attribute 'to_datetimeIndex' ”

I am getting “module ' pandas ' has no attribute ' to_datetimeIndex ' ”

Traceback:

File "c:\users\joshua lindsay\anaconda3\lib\site-packages\streamlit\script_runner.py", line 324, in _run_script
    exec(code, module.__dict__)

File "C:\Users\Joshua Lindsay\PycharmProjects\Python_project\StockWebApp.py", line 88, in <module>
    df = get_data(symbol, start, end)

File "C:\Users\Joshua Lindsay\PycharmProjects\Python_project\StockWebApp.py", line 80, in get_data
    df = df.set_index(pd.to_datetimeIndex(df['Date'].values))

File "c:\users\joshua lindsay\anaconda3\lib\site-packages\pandas\__init__.py", line 214, in __getattr__
    raise AttributeError("module 'pandas' has no attribute '{}'".format(name))

pandas has nothing called to_datetimeIndex you can use to_datetime instead.

change this line:

df = df.set_index(pd.to_datetimeIndex(df['Date'].values))

To:

df = df.set_index(pd.to_datetime(df['Date']))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM