【发布时间】:2017-10-02 15:19:11
【问题描述】:
我正在尝试使用带有 sql 结果填充数据框的 pandas autocorrelation_plot() 函数,但是当我运行此代码时,我不断收到此错误:
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
【问题讨论】:
-
你知道你要做什么吗?
-
当我打印帧的值时,我正在尝试从看起来像这样的时间序列绘制自相关: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
-
打印
df.head(10)并在此处发布。
标签: python pandas matplotlib dataframe plot