Aan de slagGa gratis aan de slag

Read data with a time index

pandas DataFrame objects can have an index denoting time, this recognized by Matplotlib for axis labeling.

This exercise involves reading data from climate_change.csv, containing CO2 levels and temperatures recorded on the 6th of each month from 1958 to 2016, using pandas' read_csv function. The parse_dates and index_col arguments help set a DateTimeIndex.

Don't forget to check out the Matplotlib Cheat Sheet for a quick overview of essential concepts and methods.

Deze oefening maakt deel uit van de cursus

Introduction to Data Visualization with Matplotlib

Cursus bekijken

Oefeninstructies

  • Import the pandas library as pd.
  • Read in the data from a CSV file called 'climate_change.csv' using pd.read_csv.
  • Use the parse_dates key-word argument to parse the "date" column as dates.
  • Use the index_col key-word argument to set the "date" column as the index.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import pandas as pd
____

# Read the data from file using read_csv
climate_change = pd.read_csv(____, ____, ____)
Code bewerken en uitvoeren