1.開始入門Pandas,而後跟着網上的例子,編寫如下代碼:python
import pandas as pd import datetime import pandas.io.data as web start = datetime.datetime(2010,1,1) end = datetime.datetime(2015,8,22) df = web.DataReader('XOM','yahoo',start,end) print(df)
2.一運行報錯信息爲:ModuleNotFoundError: No module named 'pandas.io.data' web
3.查找網上教程,發現pandas.io.data已經用不成了,得替換爲pandas_datareader,故在dos命令輸入:pip3 install pandas_datareader,在pycharm-setting導入api
4.修改後的代碼以下所示:code
import pandas as pd import datetime import pandas_datareader.data as web start = datetime.datetime(2010,1,1) end = datetime.datetime(2015,8,22) df = web.DataReader('XOM','yahoo',start,end) print(df)
5.依舊報錯:ImportError: cannot import name 'is_list_like'blog
6.查找網上教程後,須要去fred.py中修改信息,在pycharm報錯信息中,點擊C:\Users\Adinistrator\venv\Demo4\lib\site-packages\pandas_datareader\fred.py中,將from pandas.core.common import is_list_like替換爲:from pandas.api.types import is_list_like(正確方式)教程
7.繼續修改代碼後,運行,依舊報錯,報錯信息以下:ip
8.依舊尋找教程,發現錯誤緣由爲:Yahoo的數據源已經失效,使用另外一個數據源便可,最後代碼以下所示:pycharm
import pandas as pd import datetime import pandas_datareader.data as web start = datetime.datetime(2010,1,1) end = datetime.datetime(2015,8,22) df = web.DataReader('F-F_Research_Data_factors','famafrench',start,end) print(df)