Moving averages, or rolling means, are time-series filters that filter impulsive responses by averaging the set or window of observations. It uses window size concepts and finds the average of the continuous window slides for each period. The simple moving average can be represented as follows:
There are various types of moving averages available, such as centered, double, and weighted moving averages. Let's find the moving average using the rolling() function, but before that, we'll first load the data and visualize it:
# import needful libraries
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
# Read dataset
sales_data = pd.read_csv('sales.csv')
# Setting figure size
plt.figure(figsize=(10,6))
# Plot original sales data
plt.plot(sales_data['Time'], sales_data['Sales'], label="Sales-Original")
# Rotate xlabels
plt.xticks(rotation=60)
# Add legends
plt.legend...