swadhinbiswas style: apply ruff formatting · 8/1/2026
706e694
20 lines · 451 Bytes
Raw Download

« Back to Index

GroupBy in Polars

Grouping data is a core transformation operation.

Syntax

df.group_by("airline_code").agg(
    [
        pl.col("delay_minutes").mean().alias("avg_delay"),
        pl.col("flight_id").count().alias("total_flights"),
    ]
)

Polars executes these groupings in parallel, making it vastly superior to Pandas for large datasets.


« Back to Index