Rolling average air quality since 2010 for new york city
The last video was about rolling window functions. To practice this new tool, you'll start with air quality trends for New York City since 2010. In particular, you'll be using the daily Ozone concentration levels provided by the Environmental Protection Agency to calculate & plot the 90 and 360 day rolling average.
This exercise is part of the course
Manipulating Time Series Data in Python
Exercise instructions
We have already imported pandas
as pd
and matplotlib.pyplot
as plt
.
- Use
pd.read_csv()
to import'ozone.csv'
, creating aDateTimeIndex
from the'date'
column usingparse_dates
andindex_col
, and assign the result todata
. - Add the columns
'90D'
and'360D'
containing the 90 and 360 rolling calendar day.mean()
for the column'Ozone'
. - Plot
data
starting 2010, setting'New York City'
astitle
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import and inspect ozone data here
data = ____
print(____)
# Calculate 90d and 360d rolling mean for the last price
data['90D'] = ____
data['360D'] = ____
# Plot data