尝试使用 Statsmodels 中的 seasonal_decompose 时出错

Error when trying to use seasonal_decompose from Statsmodels

我有以下名为 'data' 的数据框:

Month Revenue Index
1920-01-01 1.72
1920-02-01 1.83
1920-03-01 1.94
... ...
2021-10-01 114.20
2021-11-01 115.94
2021-12-01 116.01

这本质上是一个月度收入指数,我试图在其上使用 seasonal_decompose 和以下代码:

result = seasonal_decompose(data['Revenue Index'], model='multiplicative')

但不幸的是我收到以下错误:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-39-08e3139bbf77> in <module>()
----> 1 result = seasonal_decompose(data['Consumptieprijsindex'], model='multiplicative')
      2 rcParams['figure.figsize'] = 12, 6
      3 plt.rc('lines', linewidth=1, color='r')
      4 
      5 fig = result.plot()

/usr/local/lib/python3.7/dist-packages/statsmodels/tsa/seasonal.py in seasonal_decompose(x, model, filt, freq, two_sided, extrapolate_trend)
    125             freq = pfreq
    126         else:
--> 127             raise ValueError("You must specify a freq or x must be a "
    128                              "pandas object with a timeseries index with "
    129                              "a freq not set to None")

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

有谁知道如何解决这个问题?谢谢!

评论中的以下代码回答了我的问题:

result = seasonal_decompose(data['Revenue Index'], model='multiplicative', period=12)