Professional Documents
Culture Documents
Assignment-5 - Colaboratory
Assignment-5 - Colaboratory
ipynb - Colaboratory
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
airpass = pd.read_csv('AirPasse.csv')
airpass.head(5)
Month #Passengers
0 1949-01 112
1 1949-02 118
2 1949-03 132
3 1949-04 129
4 1949-05 121
airpass.tail(5)
Month #Passengers
airpass.rename(columns={'#Passengers':'Passengers'},inplace=True)
airpass.head()
Month Passengers
0 1949-01 112
1 1949-02 118
2 1949-03 132
3 1949-04 129
4 1949-05 121
airpass.shape
(144, 2)
airpassind = airpass.set_index('Month',inplace=False)
airpass_log = np.log(airpassind)
https://colab.research.google.com/drive/1fLUYG8lu1cFA0PLuGYw7BgYphaCK_yWc#scrollTo=8rtnsyoO2thv&uniqifier=1&printMode=true 1/3
6/16/23, 8:44 PM Untitled10.ipynb - Colaboratory
rollmean_log = airpass_log.rolling(window=12).mean()
rollstd_log = airpass_log.rolling(window=12).std()
airpass_new.head()
Passengers
Month
1949-01-01 NaN
1949-02-01 NaN
1949-03-01 NaN
1949-04-01 NaN
1949-05-01 NaN
airpass_new.dropna(inplace=True)
airpass_new.head()
Passengers
Month
1949-12-01 -0.065494
1950-01-01 -0.093449
1950-02-01 -0.007566
1950-03-01 0.099416
1950-04-01 0 052142
https://colab.research.google.com/drive/1fLUYG8lu1cFA0PLuGYw7BgYphaCK_yWc#scrollTo=8rtnsyoO2thv&uniqifier=1&printMode=true 2/3
6/16/23, 8:44 PM Untitled10.ipynb - Colaboratory
[<matplotlib.lines.Line2D at 0x7f2e3a18fca0>]
decomposition = seasonal_decompose(airpass_log)
trend = decomposition.trend
seasonal = decomposition.seasonal
residual = decomposition.resid
airpass_decompose = residual
airpass_decompose.dropna(inplace=True)
rollmean_decompose = airpass_decompose.rolling(window=12).mean()
rollstd_decompose = airpass_decompose.rolling(window=12).std()
https://colab.research.google.com/drive/1fLUYG8lu1cFA0PLuGYw7BgYphaCK_yWc#scrollTo=8rtnsyoO2thv&uniqifier=1&printMode=true 3/3