Time Series with Pandas (Basics)

# Close 20 day moving average stock price
df['Close: 20 Day moving Average'] = df['Close'].rolling(20).mean() 

# upper = 20MA + 2std(20)
df['Upper'] = df['Close: 20 Day moving Average'] + 2*df['Close'].rolling(20).std() 

# lower = 20MA - 2std(20) 
df['Lower'] = df['Close: 20 Day moving Average'] - 2*df['Close'].rolling(20).std() 

# Close 
df['Close']

# plot them all in 1 plot
df[['Close', 'Upper', 'Lower', 'Close: 20 Day moving Average']].plot(figsize(16,6))

Time Series Analysis - Analysis Techniques

Agenda:

  1. Time Series Basics
  2. Statsmodels
  3. ETS Models and Decomposition
  4. ARIMA Models
  5. EWMA Models (Exponentially Weighted Moving Averages)

Time Series Basics