IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Introduction to Data Visualization with Matplotlib

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Import pandas as pd
____

# Read the data from file using read_csv
climate_change = pd.read_csv(____, ____, ____)
Modifica ed esegui il codice