1. Basics of time series

In Anaconda Powershell, install seaborn:

pip install seaborn

1. Read the daily ozone data file we used in Section 06. Read the data as ozone_data dataframe.

2. Create a new column cDate that contains string values in a format like 2020-05-01. Here we use 2020 as the year of all observations.

[Hint: Use the .astype method to convert formats, and + to combine strings]

3. Create a new column Date, where you convert cDate to Date with to_datetime method. By doing so, we convert string to Timestamp. See this for more about Timestamp.

4. Create a time series by apply ozone_data.set_index('Date').

5. By far, we have created a time series. We will take a further look at how to analyze time series in the future. For now, simply type:

ozone['Ozone'].plot()

You will get a ozone time series. For a plot with several panels, run:

# Import modules
import matplotlib.pyplot as plt
import seaborn as sns

# Columns to plot
cols_plot = ['Ozone', 'Temperature', 'Wind.Speed']
axes = ozone[cols_plot].plot(marker='.', linestyle='None', figsize=(11, 9), subplots=True)
axes[0].set_ylabel('Ozone (ppb)')
axes[1].set_ylabel('Temperature (F)')
axes[2].set_ylabel('Wind Speed (m/s)')