CommencerCommencez gratuitement

Previewing the data lazily

You've joined the Seattle city data analysis team. They track every Seattle Public Library checkout in a multi-million-row CSV, and the reporting team wants a quick peek at the data. Keep the query lazy until after head(5) so Polars only reads the rows you need.

polars is loaded as pl, and the LazyFrame library was built from the CSV file.

Cet exercice fait partie du cours

<cours>Scaling and Optimizing Data Pipelines with Polars</cours>
Voir le cours

Instructions de l’exercice

  • Take only the first 5 rows of the library LazyFrame.
  • Trigger execution and assign the resulting DataFrame to result.

Exercice interactif pratique

Essayez cet exercice en complétant ce code d’exemple.

# Preview the first 5 rows lazily, then execute
result = library.____(5).____()
print(result)
Modifier et exécuter le code