LoslegenKostenlos loslegen

Compare weekly, monthly and annual ozone trends for NYC & LA

You have seen in the video how to downsample and aggregate time series on air quality.

First, you'll apply this new skill to ozone data for both NYC and LA since 2000 to compare the air quality trend at weekly, monthly and annual frequencies and explore how different resampling periods impact the visualization.

Diese Übung ist Teil des Kurses

Manipulating Time Series Data in Python

Kurs anzeigen

Anleitung zur Übung

We have again imported pandas as pd and matplotlib.pyplot as plt for you.

  • Use pd.read_csv() to import 'ozone.csv' and set a DateTimeIndex based on the 'date' column using parse_dates and index_col, assign the result to ozone and inspect using .info().
  • Apply .resample() with weekly frequency ('W') to ozone, aggregate using .mean() and plot the result.
  • Repeat with monthly ('M') and annual ('A') frequencies, plotting each result.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import and inspect data here
ozone = ____


# Calculate and plot the weekly average ozone trend



# Calculate and plot the monthly average ozone trend



# Calculate and plot the annual average ozone trend


Code bearbeiten und ausführen