記錄 python 程式設計中遇到的錯誤
1. 記錄一個粗心大意導致的錯誤:'DataFrame' object has no attribute 'piovt'
原因是拼寫錯誤,正確的應該是 pivot
df.pivot('A','B','C')
要注意細節
2.index=pd.date_range('11/13/2018',period=1000)
出錯: TypeError: __new__() got an unexpected keyword argument 'period'
看了pandas 0.23.4 documentation 網址 http://pandas.pydata.org/pandas-docs/stable/generated/pandas.date_range.html
3.index=pd.Datetimeindex(['11/12/2018','11/22/2018‘])
出錯 AttributeError: module 'pandas' has no attribute 'Datetimeindex'
把 'Datetimeindex'中的index的i改為大寫I
4.D=Series([0,1,2,3,4,5,6,7,8,9])
pd.rolling_sum(D,2)
出錯:AttributeError: module 'pandas' has no attribute 'rolling_sum'
python版本3.7. 正確寫法:D.rolling(2).sum()
In[1]: D.rolling(2).sum()
Out[1]:
0 NaN
1 1.0
2 3.0
3 5.0
4 7.0
5 9.0
6 11.0
7 13.0
8 15.0
9 17.0
dtype: float64