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.
Latihan ini merupakan bagian dari kursus
Scaling and Optimizing Data Pipelines with Polars
Instruksi latihan
- Use the right method to execute both lazy queries at once.
- Pass
checkouts_by_formatfirst andcheckouts_by_monthsecond in the list.
Latihan interaktif langsung praktik
Cobalah latihan ini dengan melengkapi kode contoh ini.
# 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])