LoslegenKostenlos starten

Collecting two reports together

The dashboard needs two related summaries: digital checkouts by format and digital checkouts by month. Both queries scan the same CSV. Hand both lazy queries to pl.collect_all() so Polars plans them together and reads the file just once.

Two LazyFrame queries have already been built for you:

  • checkouts_by_format: total digital checkouts grouped by format.
  • checkouts_by_month: total digital checkouts grouped by month.

Diese Übung ist Teil des Kurses

<Kurs>Scaling and Optimizing Data Pipelines with Polars</Kurs>
Kurs ansehen

Übungsanweisungen

  • Use the right method to execute both lazy queries at once.
  • Pass checkouts_by_format first and checkouts_by_month second in the list.

Interaktive praktische Übung

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

# Execute both lazy queries together so Polars shares the scan
results = pl.____([
    # Pass checkouts_by_format first, then checkouts_by_month
    ____,
    ____,
])

# Inspect each result
print(results[0])
print(results[1])
Code bearbeiten und ausführen