中文Python的Pandas的 完整时间序列分析

中文Python 0 8

中文版Pandas

设 时间分析结果 = 表格.时间序列分析(CSV数据, "销售日期", "销售额", 频率="MS", 聚合方法="sum")
打印("月度重采样:", 时间分析结果["重采样数据"])
打印("时间趋势:", 时间分析结果["趋势"])

原版Pandas

月度重采样 = CSV数据.set_index("销售日期")["销售额"].resample("MS").sum()
时间趋势 = 月度重采样.rolling(window=3, center=True).mean()
print("月度重采样:", 月度重采样)
print("时间趋势:", 时间趋势)

打印信息

月度重采样: 销售日期
2026-04-01     84384
2026-05-01    446206
2026-06-01    429814
2026-07-01    534287
Freq: MS, Name: 销售额, dtype: int64
时间趋势: 销售日期
2026-04-01              NaN
2026-05-01    320134.666667
2026-06-01    470102.333333
2026-07-01              NaN
Freq: MS, Name: 销售额, dtype: float64


也许您对下面的内容还感兴趣: