Polars (LTS CPU version)

1.33.1 · active · verified Mon Apr 13

Polars is a blazingly fast DataFrame library for Python, implemented in Rust, designed for performance-critical data manipulation. The `polars-lts-cpu` package specifically provides a long-term support (LTS), CPU-only build of Polars, ensuring stability and a smaller installation footprint without GPU dependencies. It generally follows a slower release cadence than the main `polars` package, focusing on reliability. The current version is 1.33.1.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates creating a Polars DataFrame, filtering rows based on a condition, grouping data by a categorical column, aggregating results (mean and count), and finally sorting the output. It showcases basic eager DataFrame operations.

import polars as pl

# Create a DataFrame
df = pl.DataFrame(
    {
        "name": ["Alice", "Bob", "Charlie", "David", "Eve"],
        "age": [25, 30, 35, 28, 22],
        "city": ["New York", "London", "Paris", "New York", "London"],
        "score": [90, 85, 92, 78, 95],
    }
)

# Perform some operations: filter and group by city, then calculate average score
result = (
    df.filter(pl.col("age") > 25)
    .group_by("city")
    .agg(
        pl.col("score").mean().alias("average_score"),
        pl.col("name").count().alias("num_people"),
    )
    .sort("average_score", descending=True)
)

print("Original DataFrame:\n", df)
print("\nProcessed Result:\n", result)

view raw JSON →