1. 학습
  2. /
  3. 강의
  4. /
  5. Scaling and Optimizing Data Pipelines with Polars

Connected

연습 문제

Lazy pivot to wide format

The dashboard team wants a wide month-by-format view of checkouts. Polars supports .pivot() in lazy mode when you specify the output column names in advance, which keeps the whole pipeline optimized end to end.

The LazyFrame monthly_checkouts holds totals in long format with a month, format, and total column, and the list formats holds every format name in the data.

지침

100 XP
  • Pivot monthly_checkouts so each format becomes its own column.
  • Pass the formats list so the lazy pivot knows the output schema in advance.
  • Sort the resulting DataFrame by month.