尽管熊猫识别了DateTime索引,但季节性分解图不会显示

问题描述

我按如下方式加载了数据

og_data=pd.read_excel(r'C:\Users\hp\Downloads\dataframe.xlsx',index_col='DateTime')

它看起来像这样:

DateTime             A
2019-02-04 10:37:54  0
2019-02-04 10:47:54  1
2019-02-04 10:57:54  2
2019-02-04 11:07:54  3
2019-02-04 11:17:54  4

问题是,我正在尝试将数据设置为频率,但是我必须丢弃NaN值,即使我没有设置,这似乎也是一个不规则的频率。我有大熊猫可以识别索引的DateTime:

og_data.index

DatetimeIndex
dtype='datetime64[ns]',name='DateTime',length=15536,freq=None)

但是当我尝试这样做时:

og_data.index.freq = '10T'

那应该是10分钟,对吧? 但我却收到以下错误:

ValueError: Inferred frequency None from passed values does not conform to passed frequency 10T

即使我将频率设置为天:

og_data.index.freq = 'D'

我遇到类似的错误。

目标是获取季节性分解图,因为我想预测数据。但是,当我尝试这样做时,出现以下错误:

result=seasonal_decompose(og_data['A'],model='add')
result.plot();

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

这很有意义,我无法将datetime索引设置为指定的频率。我需要每10分钟一次,请告知。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...