CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Manipulating Time Series Data in Python

Afficher le cours

Instructions

We have already imported pandas as pd and matplotlib.pyplot as plt.

  • Use pd.read_csv() to import 'ozone.csv', creating a DateTimeIndex from the 'date' column using parse_dates and index_col, and assign the result to data.
  • 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' as title.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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

Modifier et exécuter le code