Pynions

Polars vs Pandas: Where the Speedup Really Comes From

Polars vs pandas after Polars 2.1 and pandas 3.1: tested code, a reproducible benchmark, API and memory differences, and when to use each library.

Updated 11 min read
Server racks with network cables in a data center

Polars wins for ETL pipelines, large files and multi-core machines; pandas wins for notebooks, small data and libraries built on its API. In our test on 8 vCPUs, Polars 2.1 ran filters, group-bys, joins and string searches roughly 5x to 16x faster than pandas 3.1. Pinned to one thread, the gap shrank to between 1x and 2.5x.

That second number matters most. Much of Polars' lead comes from using every core, so the gap you see depends on your hardware and your workload.

Key Takeaways

  • Polars is the better default for new pipelines, large files, joins and aggregations, and for data that does not fit in RAM.
  • pandas is the better fit for exploratory notebooks, existing codebases and libraries that subclass its DataFrame, such as GeoPandas.
  • In our benchmark, Polars was roughly 5x to 16x faster with 8 threads and 1x to 2.5x faster with one thread.
  • Polars 2.0 (October 2026) made the streaming engine the default for lazy queries and turned on spill-to-disk.
  • pandas 3.0 (January 2026) made Copy-on-Write and a dedicated str dtype the default, so upgrades already require code changes.
  • You can run both: Polars for the heavy transforms, pandas at the edge where a library needs it.

Polars vs Pandas: At a Glance

Feature

Polars

pandas

Current version (Nov 2026)

2.1.0

3.1.1

Core language

Rust, on Apache Arrow memory

Python and C extensions, on NumPy or Arrow

Multi-core

Yes, by default

Mostly single-threaded

Lazy queries with optimizer

Yes (LazyFrame)

No

Bigger-than-RAM data

Streaming engine, spill-to-disk on by default

No built-in path

Row index

None

Central to the API

Missing values

null, separate from NaN

NaN for the default dtypes

License

MIT

BSD-3-Clause

PyPI downloads, last 30 days

69.9 million

710.9 million

Best for

ETL, large files, production pipelines

EDA, notebooks, pandas-native libraries

Both libraries need Python 3.11 or newer in their current releases, according to their PyPI metadata.

What Is Polars?

Polars homepage

Polars is a DataFrame library for Python and Rust created by Ritchie Vink. It stores columns in Apache Arrow format and runs its query engine in Rust across all available cores.

You can use it eagerly, like pandas, or lazily. A lazy query (pl.scan_csv(), pl.scan_parquet(), df.lazy()) builds a plan first. When you call .collect(), the optimizer pushes filters into the file reader and skips columns the query never uses.

Polars reached version 1.0 on July 1, 2024. The company behind it raised a €18M Series A led by Accel in September 2025. Its paid distributed platform, formerly Polars Cloud, was renamed Polars Nanook on November 5, 2026; the open-source library stays MIT-licensed.

What Changed in Polars 2

Polars 2.0 shipped on October 6, 2026, and Polars 2.1 followed on October 27. The changes that matter for a pandas comparison:

  • LazyFrame.collect() now uses the streaming engine by default.
  • Out-of-core processing (spill to disk) is on by default and starts at about 80% of RAM; 2.1 added out-of-core group-bys.
  • The streaming engine does not guarantee row order for join and group_by. Sort explicitly, or pass maintain_order=True, when order matters.
  • Polars 2.1 dropped Python 3.10 and now raises on mixed string and number arithmetic in eager mode.

Strengths

  • Uses every core by default. No multiprocessing code needed.
  • Query optimizer. Lazy plans get predicate pushdown and column pruning before any data loads.
  • Larger-than-RAM data. Streaming and spill-to-disk let a query finish on data that does not fit in memory.

Weaknesses

  • No row index. Code built on .loc, .iloc and index alignment needs rewriting, not renaming.
  • Smaller ecosystem. Libraries that subclass pandas, like GeoPandas, do not take Polars DataFrames.
  • Two major versions in under 30 months. Code written for Polars 0.x or 1.x can need changes on 2.x, so pin your version.

What Is Pandas?

pandas homepage

pandas is an open-source data analysis and manipulation library built on Python. Its development began at AQR Capital Management in 2008, it was open-sourced by the end of 2009, and it has been a NumFOCUS sponsored project since 2015.

Its labeled index, .loc/.iloc selection and deep integration with NumPy and Matplotlib made it the default for data work in Python. Pandas still sees roughly ten times the monthly PyPI downloads of Polars.

What Changed in Pandas 3

pandas 3.0 shipped on January 21, 2026, and pandas 3.1 on October 22. Two defaults changed:

  • Copy-on-Write. Every indexing result behaves as a copy, so chained assignment such as df["col"][mask] = value never updates the original DataFrame.
  • A dedicated str dtype. String columns are inferred as str instead of object, backed by PyArrow when it is installed. Checks like dtype == "object" stop matching.

The release also removed include_groups=True from DataFrameGroupBy.apply(). Note that DataFrame.append() was already removed in pandas 2.0.

Strengths

  • Ecosystem depth. Most plotting, statistics and ML libraries accept pandas objects.
  • Notebook ergonomics. Labeled rows, .describe() and .plot() make quick exploration easy.
  • Documentation and answers. Almost two decades of tutorials, books and Q&A assume pandas.

Weaknesses

  • Mostly single-threaded. The Polars team's PDS-H write-up cites pandas' single-threaded execution and lack of a query optimizer for its gap.
  • No query optimizer. Each method runs immediately on the full data, so you prune columns and filter rows by hand.
  • Everything must fit in memory. There is no built-in streaming path for larger-than-RAM data.

Performance: Polars vs Pandas

Headline speedups range from single digits to 94x because they measure different things. Here is what each number means, and a benchmark you can run yourself.

The 94x Figure

The official PDS-H benchmark from May 2025 ran on an AWS c7a.24xlarge with 96 vCPUs. At scale factor 10 (roughly 10 GB of CSV), Polars 1.30 streaming took 3.89 seconds against 365.71 seconds for pandas 2.2.3: 94x.

Pandas was left out of the scale factor 100 run because of out-of-memory failures. The result is real, but it reflects 96 cores, a TPC-H style query suite and pandas 2.2.

A Benchmark You Can Run

To see the effect on a smaller machine, we timed four common operations on 5 million rows. Install the pinned versions first:

Shell
pip install "polars==2.1.0" "pandas==3.1.1" "pyarrow==26.0.1" "scikit-learn==1.9.1"

Save this as bench.py:

Python
import time

import numpy as np
import pandas as pd
import polars as pl

N = 5_000_000
rng = np.random.default_rng(42)
data = {
    "user_id": rng.integers(0, 100_000, N),
    "amount": rng.random(N) * 100,
    "country": rng.choice(["LT", "ES", "US", "DE", "FR"], N),
    "email": [f"user{i % 100_000}@example.com" for i in range(N)],
}
users = {"user_id": np.arange(100_000), "tier": rng.choice(["free", "pro"], 100_000)}

pdf, pusers = pd.DataFrame(data), pd.DataFrame(users)
pldf, plusers = pl.DataFrame(data), pl.DataFrame(users)


def best_of(fn, runs=3):
    times = []
    for _ in range(runs):
        start = time.perf_counter()
        fn()
        times.append(time.perf_counter() - start)
    return min(times)


tasks = {
    "filter": (
        lambda: pdf[pdf["amount"] > 50],
        lambda: pldf.filter(pl.col("amount") > 50),
    ),
    "group-by": (
        lambda: pdf.groupby("country")["amount"].agg(["sum", "mean", "max"]),
        lambda: pldf.group_by("country").agg(
            pl.col("amount").sum().alias("sum"),
            pl.col("amount").mean().alias("mean"),
            pl.col("amount").max().alias("max"),
        ),
    ),
    "join": (
        lambda: pdf.merge(pusers, on="user_id"),
        lambda: pldf.join(plusers, on="user_id"),
    ),
    "string contains": (
        lambda: pdf[pdf["email"].str.contains("99@", regex=False)],
        lambda: pldf.filter(pl.col("email").str.contains("99@", literal=True)),
    ),
}

for name, (pandas_fn, polars_fn) in tasks.items():
    t_pd, t_pl = best_of(pandas_fn), best_of(polars_fn)
    print(f"{name:<16} pandas {t_pd:6.3f}s  polars {t_pl:6.3f}s  {t_pd / t_pl:5.1f}x")

One run on an 8 vCPU Linux box with 15 GB of RAM, Python 3.15.2, printed:

Text
filter           pandas  0.096s  polars  0.008s   11.9x
group-by         pandas  0.133s  polars  0.010s   13.8x
join             pandas  0.153s  polars  0.030s    5.1x
string contains  pandas  0.166s  polars  0.013s   12.8x

Your timings will differ. Across five runs, the median speedups were 11x for the filter, 13x for the group-by, 5x for the join and 13x for the string search.

Now pin Polars to one thread with POLARS_MAX_THREADS=1 python bench.py. Over five runs, the medians fell to 2.4x for the filter, 2.2x for the group-by, 1.0x for the join and 2.5x for the string search.

What the Numbers Mean

On one core, Polars is still faster at filtering, grouping and string search, and the join is a draw. Most of the double-digit gains come from parallelism, so a laptop with 4 cores will see less than a 96-core server.

The string result is also a pandas 3 story. With PyArrow installed, string columns now use the Arrow-backed str dtype, so old benchmarks that showed little gain on string work measured the object dtype.

A VU Amsterdam study points the same way on energy. Polars used about 8 times less energy than pandas on large synthetic dataframes and about 63% of pandas' energy on TPC-H tasks with large dataframes.

Winner: Polars. It led on every operation we tested with 8 threads, and the lead grows with core count.

API and Syntax: Polars vs Pandas

The two APIs look similar for simple selects, then split on three points: Polars has no row index, its DataFrames are never modified in place, and it replaces most .apply() calls with expressions.

Here is the same per-group calculation in both libraries: the highest views value among rows whose sales beat their group's average.

Python
import pandas as pd
import polars as pl

data = {
    "id": [1, 1, 1, 2, 2, 2],
    "sales": [10, 20, 30, 5, 50, 45],
    "views": [100, 250, 300, 80, 900, 700],
}

# pandas: a Python function runs once per group
pdf = pd.DataFrame(data)
pd_result = pdf.groupby("id")[["sales", "views"]].apply(
    lambda d: d.loc[d["sales"] > d["sales"].mean(), "views"].max()
)
print(pd_result)

# Polars: one expression, evaluated in Rust
pldf = pl.DataFrame(data)
pl_result = (
    pldf.group_by("id")
    .agg(pl.col("views").filter(pl.col("sales") > pl.col("sales").mean()).max())
    .sort("id")
)
print(pl_result)

Both return 300 for group 1 and 900 for group 2:

Text
id
1    300
2    900
dtype: int64
shape: (2, 2)
┌─────┬───────┐
│ id  ┆ views │
│ --- ┆ ---   │
│ i64 ┆ i64   │
╞═════╪═══════╡
│ 1   ┆ 300   │
│ 2   ┆ 900   │
└─────┴───────┘

The .sort("id") is there on purpose. Polars does not promise group order, so sort whenever output order matters.

Common renames when you move code across:

pandas

Polars

pd.read_csv()

pl.read_csv() (eager) or pl.scan_csv() (lazy)

df.groupby()

df.group_by()

df.merge()

df.join()

df.assign(new=...)

df.with_columns(expr.alias("new"))

df.fillna()

df.fill_null()

df[mask] / df.loc[mask]

df.filter(expr)

df.apply(func)

An expression, or map_elements as a last resort

The official Coming from pandas guide lists the semantic differences, including null versus NaN.

Winner: Tie. pandas is quicker to poke at in a notebook. Polars expressions are easier to reason about in production code and run in parallel.

Pandas 3 Behavior You Need to Know

If you stay on pandas, the 3.x defaults still change how your code behaves. This snippet shows both changes:

Python
import pandas as pd

df = pd.DataFrame({"city": ["Vilnius", "Madrid"], "temp_c": [3, 14]})
print(df["city"].dtype)
print(df["city"].dtype == "object")

df["temp_c"][df["city"] == "Madrid"] = 20  # chained assignment
print(df["temp_c"].tolist())

df.loc[df["city"] == "Madrid", "temp_c"] = 20  # one indexing step
print(df["temp_c"].tolist())

With pandas 3.1.1 it prints:

Text
str
False
[3, 14]
[3, 20]

The chained assignment also emits a ChainedAssignmentError warning and leaves the data unchanged. The single .loc assignment works. Polars avoids the whole class of problem because you always build a new DataFrame with with_columns().

Lazy Queries and Memory: Polars vs Pandas

Polars' biggest structural advantage is the lazy API. You describe the whole query, and Polars decides what to read:

Python
import polars as pl

pl.DataFrame(
    {
        "order_date": ["2026-01-05", "2026-02-11", "2026-03-02", "2026-03-09"],
        "region": ["EU", "US", "EU", "US"],
        "amount": [120.0, 80.0, 200.0, 40.0],
    }
).write_csv("orders.csv")

lf = (
    pl.scan_csv("orders.csv", try_parse_dates=True)
    .filter(pl.col("order_date") >= pl.date(2026, 2, 1))
    .group_by("region")
    .agg(pl.col("amount").sum().alias("revenue"))
    .sort("region")
)
print(type(lf).__name__)
print(lf.collect())

Output:

Text
LazyFrame
shape: (2, 2)
┌────────┬─────────┐
│ region ┆ revenue │
│ ---    ┆ ---     │
│ str    ┆ f64     │
╞════════╪═════════╡
│ EU     ┆ 200.0   │
│ US     ┆ 120.0   │
└────────┴─────────┘

Nothing is read until .collect(). Call lf.explain() before collecting and the plan shows the date filter inside the CSV scan, so rows that fail it never reach the group-by.

In Polars 2, .collect() runs on the streaming engine. It can spill to disk once memory use passes about 80% of RAM. pandas loads the whole file into memory first; for data larger than RAM you chunk it yourself.

Winner: Polars. Lazy plans, streaming and spill-to-disk have no built-in pandas equivalent.

Ecosystem and Integrations: Polars vs Pandas

pandas still has the wider ecosystem, but the gap is smaller than it was.

  • scikit-learn: transformers can return Polars output via set_output(transform="polars") since 1.4. In our test, scikit-learn 1.9.1 also fit a model directly on a Polars DataFrame and kept the column names.
  • DuckDB: can query Polars DataFrames by variable name and return results as Polars.
  • PyTorch: Polars has a built-in to_torch() method.
  • Narwhals: a compatibility layer that lets library authors support pandas and Polars with one code path.

The hard gaps are libraries built on pandas itself. GeoPandas' GeoDataFrame is a subclass of pandas.DataFrame, so geospatial work still runs through pandas. The Polars team said in the 2.0 release that it has started work on GeoPolars.

Moving data between the two is cheap. pl.from_pandas(df) and df.to_pandas(use_pyarrow_extension_array=True) share Arrow buffers when the types allow it, though the Polars team notes some schemas still trigger a partial copy.

Winner: pandas. It still works with more libraries out of the box, especially in geospatial and statistics.

Migration Cost: Polars vs Pandas

A pandas to Polars move is a rewrite, not a find-and-replace. The usual work:

  • Remove .loc, .iloc, set_index() and reset_index() logic, since Polars has no index
  • Replace .apply() with expressions
  • Swap `pd.read_ for pl.scan_ and add one .collect()` at the end
  • Decide where NaN and null should differ
  • Add sort() or maintain_order=True where row order matters

The Polars team's own migration guide recommends starting with one segment that has a measurable problem, such as a job that runs out of memory. Capture its input and output, rewrite it, and check the result with polars.testing.assert_frame_equal.

The same post reports that Check Technologies migrated more than 100 Airflow DAGs in under two weeks and cut its cloud bill by 25%. These are company-reported figures.

On r/Python, u/GunZinn described a common first encounter: "I was parsing a 4GB csv file last week. Polars was nearly 18x faster than using pandas."

Winner: Tie. New projects pay no migration cost with Polars. Large pandas codebases face real work, but pandas 3 upgrades already force you to touch chained assignment and string checks.

The Hybrid Pattern: Using Polars and Pandas Together

You do not have to choose one library for the whole stack. A common pattern is Polars for the heavy transforms and a single conversion at the edge where a library needs pandas:

Python
import polars as pl
from sklearn.linear_model import LogisticRegression

events = pl.DataFrame(
    {
        "user_id": [1, 1, 2, 2, 3, 3, 4, 4],
        "minutes": [5.0, 7.0, 40.0, 35.0, 3.0, 2.0, 50.0, 45.0],
        "pages": [2, 3, 12, 10, 1, 1, 15, 14],
    }
)
labels = pl.DataFrame({"user_id": [1, 2, 3, 4], "upgraded": [0, 1, 0, 1]})

# Heavy lifting in Polars
features = (
    events.lazy()
    .group_by("user_id")
    .agg(
        pl.col("minutes").mean().alias("avg_minutes"),
        pl.col("pages").sum().alias("total_pages"),
    )
    .join(labels.lazy(), on="user_id")
    .sort("user_id")
    .collect()
)
print(features)

# scikit-learn accepts the Polars DataFrame directly
X = features.select("avg_minutes", "total_pages")
y = features["upgraded"]
model = LogisticRegression().fit(X, y)
print(model.feature_names_in_)
print(model.predict(X))

# Libraries that still need pandas get one conversion at the boundary
pdf = features.to_pandas(use_pyarrow_extension_array=True)
print(type(pdf).__name__, pdf["avg_minutes"].dtype)

Output with scikit-learn 1.9.1:

Text
shape: (4, 4)
┌─────────┬─────────────┬─────────────┬──────────┐
│ user_id ┆ avg_minutes ┆ total_pages ┆ upgraded │
│ ---     ┆ ---         ┆ ---         ┆ ---      │
│ i64     ┆ f64         ┆ i64         ┆ i64      │
╞═════════╪═════════════╪═════════════╪══════════╡
│ 1       ┆ 6.0         ┆ 5           ┆ 0        │
│ 2       ┆ 37.5        ┆ 22          ┆ 1        │
│ 3       ┆ 2.5         ┆ 2           ┆ 0        │
│ 4       ┆ 47.5        ┆ 29          ┆ 1        │
└─────────┴─────────────┴─────────────┴──────────┘
['avg_minutes' 'total_pages']
[0 1 0 1]
DataFrame double[pyarrow]

Double River, a quantitative hedge fund, took the idea further in a Polars case study. Moving one model's regressions from statsmodels into a Polars plugin cut a daily run from about 120 minutes to 9 minutes and memory from about 75 GB to 42 GB.

For more Polars patterns, see our Polars Python guide. If you are weighing other engines too, our list of pandas alternatives covers DuckDB, PySpark and more.

Which Should You Use? Polars vs Pandas

Choose Polars if you are starting a new pipeline, your data runs from hundreds of megabytes to beyond RAM, your jobs are heavy on joins and group-bys, or you run on many cores.

Choose pandas if you have a large pandas codebase, depend on GeoPandas or other pandas-native libraries, or mostly explore small datasets in notebooks.

Choose both if you want Polars speed for transforms and pandas compatibility at a few boundaries. Convert once at each boundary, not inside loops. For the wider workflow, see our Python data analysis guide.

Frequently Asked Questions

Related Articles