

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Polars
incomplete
2: Basic Operations
incomplete
3: Polars vs. Pandas
incomplete
4: Expression-Based Operations
incomplete
5: Lazy vs. Eager Execution
incomplete
6: No Index
incomplete
7: Filtering With No Index
incomplete
8: Index Alternatives
incomplete
9: Sorting
incomplete
10: Sorting Footguns
incomplete
11: Time-Based Operations
incomplete
12: Parquet
incomplete
13: Parquet With Polars
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Polars has great Parquet support. Use pl.read_parquet() to read a Parquet file into a DataFrame:
df = pl.read_parquet("sales_data.parquet")
You can also use lazy mode with Parquet for even better performance:
df = (
pl.scan_parquet("large_data.parquet") # Lazy scan
.filter(pl.col("year") == 2024)
.select(["product", "revenue"])
.collect()
)
The pl.scan_parquet() function builds a lazy query. Polars can use that query to read only the columns and row groups that it needs.
Polars can write Parquet too:
df.write_parquet("filtered_sales.parquet")
Use write_parquet() when you want to save a processed DataFrame back to disk.
Parquet files are usually compressed. Polars supports several compression options, including the modern zstd algorithm:
df.write_parquet("filtered_sales.parquet", compression="zstd")
Our browser-based Python environment has limited support for Polars' native Parquet writer, so this lesson's assignment includes a small write_parquet() helper for you to call. You won't need it in the real world.
SnackStack's telemetry archive is getting large, so the analytics team wants to build smaller Parquet extracts for focused analysis.
Complete the export_device_type_report function. It accepts the source_path of an input Parquet file; an output_path to write results to a new Parquet file; a device_type; and a list of columns.