2024-09-29 17:19:21 发布
网友
我试图从10秒的记录数据中计算15分钟、8小时和24小时的移动平均值。我应该如何设置开始时间和结束时间来计算移动平均线
我使用了以下代码来计算移动平均线
Gas_432.set_index('RecTime').rolling(90).mean() Gas_432.between_time('2019-05-31 00:00:00','2019-07-04 08:08:21')
但我收到一条错误信息 TypeError: Index must be DatetimeIndex
TypeError: Index must be DatetimeIndex
在创建DatetimeIndex之后使用^{}:
DatetimeIndex
#if not datetimes Gas_432['RecTime'] = pd.to_datetime(Gas_432['RecTime']) Gas_432 = (Gas_432.set_index('RecTime') .truncate('2019-05-31 00:00:00','2019-07-04 08:08:21') .rolling(90) .mean())
在创建} :
DatetimeIndex
之后使用^{相关问题 更多 >
编程相关推荐