用不规则时间序列生成自相关图?

2024-06-17 09:10:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我在做一个数据科学项目,我试图利用以前的警察局来预测未来的警察局。我试着做一个时间和地理空间经度的自相关图,但是当我试着做这个图的时候,我总是得到一个错误。这使我无法找到正确的滞后来建立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\u PHONEPICKUP是dtype:datetime64[ns],GEO\u LON是dtype:float64。我是否设置了错误的自相关图


Tags: 数据fromimportpandasdatetimetimeplot错误