【问题标题】:Creating autocorrelation plot with irregular time series?创建具有不规则时间序列的自相关图?
【发布时间】:2020-03-09 21:37:51
【问题描述】:

我正在做一个数据科学项目,我试图利用之前的警察站来预测未来的警察站。我正在尝试制作时间与地理空间经度的自相关图,但是当我尝试制作该图时,我不断收到错误消息。这使我无法找到正确的滞后来制作 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 的数据类型为:datetime64[ns],GEO_LON 的数据类型为:float64。我是否错误地设置了自相关图?

【问题讨论】:

    标签: python pandas matplotlib data-science


    【解决方案1】:

    我认为问题出在时间结构上,也许您应该尝试索引您的时间并查看 ACP 去。

    可能是这样的:

    autocorrelation_plot(df.set_index('time'))
    plt.show()
    

    查看 pandas 的文档pandas dataframe set_index

    【讨论】:

      猜你喜欢
      • 2012-05-12
      • 2011-06-16
      • 2021-01-08
      • 2019-03-25
      • 2020-07-21
      • 2017-01-23
      • 1970-01-01
      • 2011-04-23
      • 2011-09-26
      相关资源
      最近更新 更多