3. Linear Regression
Activity 3.01: Plotting Data with a Moving Average
- Load the two required packages:
import pandas as pd import matplotlib.pyplot as plt
- Load the dataset into a pandas DataFrame from the CSV file:
df = pd.read_csv('../Datasets/austin_weather.csv') df.head()
The output will show the initial five rows of the
austin_weather.csv
file: - Since we only need the
Date
andTempAvgF
columns, we'll remove all the other columns from the dataset:df = df.loc[:, ['Date', 'TempAvgF']] df.head()
The output will be as follows:
- Initially, we are only interested in the first year's data, so we need to extract that information only. Create a column in the DataFrame for the year value, extract the year value as an integer from the strings in the
Date
column...