

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
Unlike Pandas, Polars leans hard on an expression-based API. You usually build expressions with the pl.col() function, which means "use this column in an operation."
To filter for devices with temperatures above 80, use df.filter():
df.filter(pl.col("temperature_c") > 80)
To select the device_id and temperature_c columns, use df.select():
df.select(["device_id", "temperature_c"])
df.select(pl.col("device_id"), pl.col("temperature_c"))
To add or replace columns, use df.with_columns(). For example, to convert Celsius readings to Fahrenheit:
df.with_columns(((pl.col("temperature_c") * 9 / 5) + 32).alias("temperature_f"))
The .alias() method names the new column.
SnackStack's billing team needs a clean report of high-value transactions.
Complete the prepare_transaction_report function. It accepts a Polars DataFrame of transactions and returns a new, report-ready DataFrame.
DataFrame and updating it with each operation.pl.col() expressions will go inside the .filter() and .with_columns() calls.