image_output_1.png
from statsmodels.tsa.seasonal import seasonal_decompose

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data_orig = pd.read_csv('/kaggle/input/daily-min-temperatures/daily-min-temperatures.csv')

data_orig['Date'] = pd.to_datetime(data_orig['Date']) # convert date column to datetime
ax = data_orig.plot(x='Date', y='Temp', figsize=(12,6))

ax = data_orig.plot(x='Date', y='Temp', figsize=(12,6))
xcoords = ['1981-01-01', '1982-01-01', '1983-01-01', '1984-01-01', '1985-01-01', '1986-01-01', '1987-01-01', '1988-01-01', '1989-01-01', '1990-01-01', '1990-12-31']
for xc in xcoords:
    plt.axvline(x=xc, color='black', linestyle='--')
# The temperature seem to go down in the beginning of every year.
# And then slowly go up until the mid of year during which the temperature peaks.
# And again it starts to dip slowly until the end of year.
# We can see this repetitive seasonal trend.

from statsmodels.tsa.seasonal import seasonal_decompose
data_orig.set_index('Date', inplace=True)
data_orig.sort_index(inplace=True)
analysis = data_orig[['Temp']].copy()
decompose_result_mult = seasonal_decompose(analysis, model='additive', period=365)
decompose_result_mult.plot()