

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
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
In Pandas, we can sort by a column or by the index:
# Sort by the price column
df = df.sort_values("price")
# Sort by index
df = df.sort_index()
In Polars, with no index available, the sort() method sorts by columns or expressions:
# Sort by the price column
df = df.sort("price")
Say we had a DataFrame of RPG character stats, and we wanted to sort by the sum of attack_rating and luck_bonus. In Pandas, you'd often create a temporary calculated column. In Polars, you can sort by an expression directly:
df = df.sort(pl.col("attack_rating") + pl.col("luck_bonus"))
SnackStack's support team needs a queue of devices where those with the lowest combined battery_pct and signal_pct should be reviewed first.
Complete the build_service_queue function. It accepts a Polars DataFrame of device status rows and returns a new DataFrame.