Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Manipulating Time Series Data in Python

Cursus bekijken

Oefeninstructies

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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import and inspect ozone data here
data = ____
print(____)

# Calculate 90d and 360d rolling mean for the last price
data['90D'] = ____
data['360D'] = ____

# Plot data

Code bewerken en uitvoeren