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 byformat.checkouts_by_month: total digital checkouts grouped by month.
This exercise is part of the course
Scaling and Optimizing Data Pipelines with Polars
Exercise instructions
- Use the right method to execute both lazy queries at once.
- Pass
checkouts_by_formatfirst andcheckouts_by_monthsecond in the list.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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])