我正在做一个数据科学项目,试图利用以前的警察站点来预测未来的站点。我正在尝试绘制时间与地理空间经度的自相关图,但是当我尝试绘制该图时,我总是遇到错误。这使我无法找到建立ARIMA模型的正确滞后。
from pandas import datetime
from pandas import to_datetime
from matplotlib import pyplot
from pandas.plotting import autocorrelation_plot
dataSet = read_excel('SeniorProject.xlsx', header=0,
encoding = "ISO-8859-1")
mini = dataSet[['TIME_PHONEPICKUP','GEO_LON']]
#print(mini)
#mini.plot(x='TIME_PHONEPICKUP',y='GEO_LON', color='blue')
autocorrelation_plot(mini)
pyplot.show()
错误
TypeError: unsupported operand type(s) for +: 'Timestamp' and 'Timestamp'
UserWarning: Requested projection is different from current axis projection, creating new axis with requested projection.
ax = plt.gca(xlim=(1, n), ylim=(-1.0, 1.0))
During handling of the above exception, another exception occurred:
KeyError: '__name__'
一些样本数据
TIME_PHONEPICKUP GEO_LON
0 2019-09-09 03:57:08 -105.025060
1 2019-09-09 03:55:39 -104.990248
2 2019-09-09 03:52:32 -104.925776
3 2019-09-09 03:49:44 -105.032151
4 2019-09-09 03:45:23 -105.029842
TIME_PHONEPICKUP是dtype:datetime64 [ns],而GEO_LON是dtype:float64。我是否正确设置了自相关图?
答案 0 :(得分:0)
我认为问题出在时间结构上,也许您应该尝试编制时间索引,看看如何 ACP去了。
也许是这样的:
autocorrelation_plot(df.set_index('time'))
plt.show()
的文档