看起来你的freq
设置不正确。
import numpy as np
import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
# Generate some data
np.random.seed(0)
n = 1500
dates = np.array('2005-01-01', dtype=np.datetime64) + np.arange(n)
data = 12*np.sin(2*np.pi*np.arange(n)/365) + np.random.normal(12, 2, 1500)
df = pd.DataFrame({'data': data}, index=dates)
# Reproduce the example in OP
seasonal_decompose(df, model='additive', freq=1).plot()
# Redo the same thing, but with the known frequency
seasonal_decompose(df, model='additive', freq=365).plot()