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之后,把period改为periods好了。
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
5.conn = pymysql.connect(host = 'localhost', user = 'root', password = '123456', port = '3306', db = 'mysql')
出错:TypeError: %d format: a number is required, not str
原因:port = '3306',写错了,应该去掉引号。正确写法:port = 3306