這是我想大熊貓DataReader的提高AttributeError的:模塊「pandas.io」有沒有屬性「數據」
import matplotlib.pyplot as plt
import pandas as pd
ticker = 'GLD'
begdate = '2014-11-11'
enddate = '2016-11-11'
data1 = pd.io.data.DataReader(ticker,'yahoo',dt.datetime(2014,11,11),dt.datetime(2016,11,11))
gld_df = pd.DataFrame(data1)
date_df = pd.to_datetime(list(gld_df.index))
adj_close_df = list(gld_df["Adj Close"])
plt.plot(date_df,adj_close_df)
plt.title("SPDR Gold Shares ")
它給我下面的錯誤代碼。幾天前,當我嘗試了相同的代碼時沒有錯誤。
runfile('D:/Quant/MSQF/4 - Algorithms 1/3-Sorting/Mini Project 2_v2.py', wdir='D:/Quant/MSQF/4 - Algorithms 1/3-Sorting')
Traceback (most recent call last):
File "<ipython-input-10-db75eb5622f8>", line 1, in <module>
runfile('D:/Quant/MSQF/4 - Algorithms 1/3-Sorting/Mini Project 2_v2.py', wdir='D:/Quant/MSQF/4 - Algorithms 1/3-Sorting')
File "D:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
execfile(filename, namespace)
File "D:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/Quant/MSQF/4 - Algorithms 1/3-Sorting/Mini Project 2_v2.py", line 18, in <module>
data1 = pd.io.data.DataReader(ticker,'yahoo',dt.datetime(2014,11,11),dt.datetime(2016,11,11))
AttributeError: module 'pandas.io' has no attribute 'data'
我使用的是Anaconda,Python 3.x。這是熊貓問題還是我的系統出現問題?
僅供參考 - '''PIP安裝data_reader'''沒有爲我工作。它是'''pip安裝pandas_datareader''' –
謝謝,我已更新該帖子。 – ayhan