我试图将pandas autocorrelation_plot()函数与sql结果填充数据框一起使用,但是当我运行此代码时,我不断收到此错误:
import MySQLdb
import pandas as pd
from matplotlib import pyplot
from pandas.tools.plotting import autocorrelation_plot
connection = MySQLdb.connect(host = "host", user = "user", passwd = "passwd", db = "db")
exect = connection.cursor()
query = "query"
exect.execute(query)
frame = pd.read_sql(query, con=connection)
connection.close()
print(frame.head())
autocorrelation_plot(frame)
pyplot.show()
我可以毫无问题地打印帧,但是当我尝试使用autocorrelation_plot()函数时,我得到了这个错误。我的数据框输出如下:
time value
0 00:00:14 283.80
1 00:01:14 271.97
2 00:02:14 320.53
3 00:03:14 346.78
4 00:04:14 280.72
5 00:05:14 277.41
6 00:06:14 308.65
7 00:07:14 321.27
8 00:08:14 320.68
9 00:09:14 332.32