我下面這個教程:https://www.youtube.com/watch?v=wfTABU8VeoY&list=PLQVvvaa0QuDfHt4XU7vTm22xDegR0v0fQ&index=7與大熊貓的數據分析,但是當我想下面的代碼運行溢出錯誤與熊貓
import datetime
import pandas as pd
from pandas import DataFrame
import pandas.io.data
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
sp500 = pd.io.data.get_data_yahoo('%5EGSPC', start = datetime.datetime(2015, 10, 15),
end = datetime.datetime(2016, 10, 15))
sp500.to_csv('sp500.csv')
df = pd.read_csv('sp500.csv', index_col = 'Date', parse_dates=True)
df['H-L'] = df['High'] - df.Low
df['100MA'] = pd.rolling_mean(df['Close'], 100)
df['Difference'] = df['Close'].diff()
threedee = plt.figure().gca(projection='3d')
threedee.scatter(df.index, df['H-L'], df['Close'])
threedee.set_xlabel('Index')
threedee.set_zlabel('Close')
threedee.set_ylabel('H-L')
plt.show()
它無論是在Jupyter筆記本電腦和PyCharm錯誤產生如下:
OverflowError Traceback (most recent call last)
C:\Program Files\Anaconda2\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
305 pass
306 else:
--> 307 return printer(obj)
308 # Finally look for special method names
309 method = get_real_method(obj, self.print_method)
C:\Program Files\Anaconda2\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig)
225
226 if 'png' in formats:
--> 227 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
228 if 'retina' in formats or 'png2x' in formats:
229 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
C:\Program Files\Anaconda2\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
117
118 bytes_io = BytesIO()
--> 119 fig.canvas.print_figure(bytes_io, **kw)
120 data = bytes_io.getvalue()
121 if fmt == 'svg':
與許多其他各種路徑,包括matplotlib.py等。 有什麼問題?加載的數據不是太多,是嗎?
請出示完整的追溯,並指出這行你的腳本導致了'OverflowError'。知道您使用的是哪個版本的Pandas也是有用的:當前版本不支持「pandas.io.data」。 –
我追加了更多的回溯問題。我使用的是與Anaconda 2.7教程中相同版本的熊貓,以更順利地運行。 –