narwhals 2.18.1


pip install narwhals

  Latest version

Released: Mar 24, 2026


Meta
Author: Marco Gorelli
Requires Python: >=3.9

Classifiers

Development Status
  • 5 - Production/Stable

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Programming Language
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: Free Threading :: 2 - Beta

Typing
  • Typed

Narwhals

narwhals_small

PyPI version Downloads Trusted publishing PYPI - Types

Extremely lightweight and extensible compatibility layer between dataframe libraries!

  • Full API support: cuDF, Modin, pandas, Polars, PyArrow.
  • Lazy-only support: Daft, Dask, DuckDB, Ibis, PySpark, SQLFrame.

Seamlessly support all, without depending on any!

  • Just use a subset of the Polars API, no need to learn anything new
  • Zero dependencies, Narwhals only uses what the user passes in so your library can stay lightweight
  • ✅ Separate lazy and eager APIs, use expressions
  • ✅ Support pandas' complicated type system and index, without either getting in the way
  • 100% branch coverage, tested against pandas and Polars nightly builds
  • Negligible overhead, see overhead
  • ✅ Let your IDE help you thanks to full static typing, see typing
  • Perfect backwards compatibility policy, see stable api for how to opt-in

Get started!

Table of contents

Installation

  • pip (recommended, as it's the most up-to-date)
    pip install narwhals
    
  • conda-forge (also fine, but the latest version may take longer to appear)
    conda install -c conda-forge narwhals
    

Usage

There are three steps to writing dataframe-agnostic code using Narwhals:

  1. use narwhals.from_native to wrap a pandas/Polars/Modin/cuDF/PyArrow DataFrame/LazyFrame in a Narwhals class

  2. use the subset of the Polars API supported by Narwhals

  3. use narwhals.to_native to return an object to the user in its original dataframe flavour. For example:

    • if you started with pandas, you'll get pandas back
    • if you started with Polars, you'll get Polars back
    • if you started with Modin, you'll get Modin back (and compute will be distributed)
    • if you started with cuDF, you'll get cuDF back (and compute will happen on GPU)
    • if you started with PyArrow, you'll get PyArrow back

narwhals_gif

Example

Narwhals allows you to define dataframe-agnostic functions. For example:

import narwhals as nw
from narwhals.typing import IntoFrameT


def agnostic_function(
    df_native: IntoFrameT,
    date_column: str,
    price_column: str,
) -> IntoFrameT:
    return (
        nw.from_native(df_native)
        .group_by(nw.col(date_column).dt.truncate("1mo"))
        .agg(nw.col(price_column).mean())
        .sort(date_column)
        .to_native()
    )

You can then pass pandas.DataFrame, polars.DataFrame, polars.LazyFrame, duckdb.DuckDBPyRelation, pyspark.sql.DataFrame, pyarrow.Table, and more, to agnostic_function. In each case, no additional dependencies will be required, and computation will stay native to the input library:

import pandas as pd
import polars as pl
from datetime import datetime

data = {
    "date": [datetime(2020, 1, 1), datetime(2020, 1, 8), datetime(2020, 2, 3)],
    "price": [1, 4, 3],
}
print("pandas result:")
print(agnostic_function(pd.DataFrame(data), "date", "price"))
print()
print("Polars result:")
print(agnostic_function(pl.DataFrame(data), "date", "price"))
pandas result:
        date  price
0 2020-01-01    2.5
1 2020-02-01    3.0

Polars result:
shape: (2, 2)
┌─────────────────────┬───────┐
│ date                ┆ price │
│ ---                 ┆ ---   │
│ datetime[μs]        ┆ f64   │
╞═════════════════════╪═══════╡
│ 2020-01-01 00:00:00 ┆ 2.5   │
│ 2020-02-01 00:00:00 ┆ 3.0   │
└─────────────────────┴───────┘

See the tutorial for several examples!

Scope

  • Do you maintain a dataframe-consuming library?
  • Do you have a specific Polars function in mind that you would like Narwhals to have in order to make your work easier?

If you said yes to both, we'd love to hear from you!

Roadmap

See roadmap discussion on GitHub for an up-to-date plan of future work.

Used by

Join the party!

Feel free to add your project to the list if it's missing, and/or chat with us on Discord if you'd like any support.

Sponsors and institutional partners

Narwhals is 100% independent, community-driven, and community-owned. We are extremely grateful to the following organisations for having provided some funding / development time:

If you contribute to Narwhals on your organization's time, please let us know. We'd be happy to add your employer to this list!

Support

If you'd like to say "thank you", please give us a ⭐ star ⭐.

Please contact hello_narwhals@proton.me if you would like to:

  • Receive professional support (e.g., if you're using or would like to use Narwhals at your company).
  • Have any Narwhals fixes / features prioritised.
  • Commission any Narwhals plugins for new backends.

Appears on

Narwhals has been featured in several talks, podcasts, and blog posts:

Why "Narwhals"?

Coz they are so awesome.

Thanks to Olha Urdeichuk for the illustration!

2.18.1 Mar 24, 2026
2.18.0 Mar 10, 2026
2.17.0 Feb 23, 2026
2.16.0 Feb 02, 2026
2.15.0 Jan 06, 2026
2.14.0 Dec 16, 2025
2.13.0 Dec 01, 2025
2.12.0 Nov 17, 2025
2.11.0 Nov 10, 2025
2.10.2 Nov 04, 2025
2.10.1 Oct 31, 2025
2.10.0 Oct 27, 2025
2.9.0 Oct 20, 2025
2.8.0 Oct 13, 2025
2.7.0 Oct 06, 2025
2.6.0 Sep 29, 2025
2.5.0 Sep 12, 2025
2.4.0 Sep 08, 2025
2.3.0 Sep 01, 2025
2.2.0 Aug 25, 2025
2.1.2 Aug 15, 2025
2.1.1 Aug 12, 2025
2.1.0 Aug 11, 2025
2.0.1 Jul 29, 2025
2.0.0 Jul 28, 2025
1.48.1 Jul 24, 2025
1.48.0 Jul 21, 2025
1.47.1 Jul 17, 2025
1.47.0 Jul 14, 2025
1.46.0 Jul 07, 2025
1.45.0 Jul 01, 2025
1.44.0 Jun 23, 2025
1.43.1 Jun 19, 2025
1.43.0 Jun 16, 2025
1.42.1 Jun 12, 2025
1.42.0 Jun 09, 2025
1.41.1 Jun 06, 2025
1.41.0 May 26, 2025
1.40.0 May 19, 2025
1.39.1 May 15, 2025
1.39.0 May 12, 2025
1.38.2 May 08, 2025
1.38.1 May 08, 2025
1.38.0 May 05, 2025
1.37.1 Apr 29, 2025
1.37.0 Apr 28, 2025
1.36.0 Apr 23, 2025
1.35.0 Apr 14, 2025
1.34.1 Apr 09, 2025
1.34.0 Apr 07, 2025
1.33.0 Mar 31, 2025
1.32.0 Mar 24, 2025
1.31.0 Mar 17, 2025
1.30.0 Mar 10, 2025
1.29.1 Mar 06, 2025
1.29.0 Mar 03, 2025
1.28.0 Feb 24, 2025
1.27.1 Feb 17, 2025
1.27.0 Feb 17, 2025
1.26.0 Feb 10, 2025
1.25.2 Feb 06, 2025
1.25.1 Feb 05, 2025
1.25.0 Feb 03, 2025
1.24.2 Feb 01, 2025
1.24.1 Jan 28, 2025
1.24.0 Jan 27, 2025
1.23.0 Jan 20, 2025
1.22.0 Jan 13, 2025
1.21.1 Jan 07, 2025
1.21.0 Jan 06, 2025
1.20.1 Dec 30, 2024
1.20.0 Dec 30, 2024
1.19.1 Dec 23, 2024
1.19.0 Dec 19, 2024
1.18.4 Dec 15, 2024
1.18.3 Dec 13, 2024
1.18.2 Dec 13, 2024
1.18.1 Dec 13, 2024
1.18.0 Dec 13, 2024
1.17.0 Dec 10, 2024
1.16.0 Dec 07, 2024
1.15.2 Dec 03, 2024
1.15.1 Dec 01, 2024
1.15.0 Nov 30, 2024
1.14.3 Nov 28, 2024
1.14.2 Nov 23, 2024
1.14.1 Nov 19, 2024
1.14.0 Nov 18, 2024
1.13.5 Nov 13, 2024
1.13.4 Nov 12, 2024
1.13.3 Nov 08, 2024
1.13.2 Nov 05, 2024
1.13.1 Nov 03, 2024
1.12.1 Oct 29, 2024
1.12.0 Oct 29, 2024
1.11.1 Oct 28, 2024
1.11.0 Oct 27, 2024
1.10.0 Oct 21, 2024
1.9.4 Oct 17, 2024
1.9.3 Oct 11, 2024
1.9.2 Oct 09, 2024
1.9.1 Oct 04, 2024
1.9.0 Oct 01, 2024
1.8.4 Sep 27, 2024
1.8.3 Sep 24, 2024
1.8.2 Sep 20, 2024
1.8.1 Sep 15, 2024
1.8.0 Sep 13, 2024
1.7.0 Sep 11, 2024
1.6.4 Sep 09, 2024
1.6.3 Sep 08, 2024
1.6.2 Sep 03, 2024
1.6.1 Sep 03, 2024
1.6.0 Aug 30, 2024
1.5.5 Aug 24, 2024
1.5.4 Aug 23, 2024
1.5.3 Aug 23, 2024
1.5.2 Aug 21, 2024
1.5.1 Aug 21, 2024
1.5.0 Aug 20, 2024
1.4.2 Aug 15, 2024
1.4.1 Aug 14, 2024
1.4.0 Aug 13, 2024
1.3.0 Aug 09, 2024
1.2.0 Aug 07, 2024
1.1.9 Jul 30, 2024
1.1.8 Jul 28, 2024
1.1.7 Jul 25, 2024
1.1.6 Jul 24, 2024
1.1.5 Jul 23, 2024
1.1.4 Jul 22, 2024
1.1.3 Jul 21, 2024
1.1.2 Jul 19, 2024
1.1.1 Jul 16, 2024
1.1.0 Jul 14, 2024
1.0.6 Jul 12, 2024
1.0.5 Jul 11, 2024
1.0.4 Jul 10, 2024
1.0.3 Jul 09, 2024
1.0.2 Jul 08, 2024
1.0.1 Jul 08, 2024
1.0.0 Jul 07, 2024
0.9.29 Jul 07, 2024
0.9.28 Jul 04, 2024
0.9.27 Jul 04, 2024
0.9.26 Jul 03, 2024
0.9.25 Jul 03, 2024
0.9.24 Jul 02, 2024
0.9.23 Jul 01, 2024
0.9.22 Jul 01, 2024
0.9.21 Jun 30, 2024
0.9.20 Jun 30, 2024
0.9.19 Jun 30, 2024
0.9.18 Jun 30, 2024
0.9.17 Jun 27, 2024
0.9.16 Jun 22, 2024
0.9.15 Jun 21, 2024
0.9.14 Jun 20, 2024
0.9.13 Jun 19, 2024
0.9.12 Jun 17, 2024
0.9.11 Jun 16, 2024
0.9.10 Jun 15, 2024
0.9.9 Jun 13, 2024
0.9.8 Jun 12, 2024
0.9.7 Jun 12, 2024
0.9.6 Jun 11, 2024
0.9.5 Jun 10, 2024
0.9.2 Jun 04, 2024
0.9.1 Jun 03, 2024
0.9.0 Jun 02, 2024
0.8.21 Jun 01, 2024
0.8.20 Jun 01, 2024
0.8.19 May 28, 2024
0.8.18 May 24, 2024
0.8.17 May 23, 2024
0.8.16 May 21, 2024
0.8.15 May 17, 2024
0.8.14 May 15, 2024
0.8.13 May 14, 2024
0.8.12 May 12, 2024
0.8.11 May 11, 2024
0.8.10 May 11, 2024
0.8.9 May 10, 2024
0.8.8 May 09, 2024
0.8.7 May 09, 2024
0.8.6 May 08, 2024
0.8.5 May 08, 2024
0.8.4 May 08, 2024
0.8.3 May 08, 2024
0.8.2 May 08, 2024
0.8.1 May 08, 2024
0.8.0 May 07, 2024
0.7.18 May 07, 2024
0.7.16 May 05, 2024
0.7.15 Apr 30, 2024
0.7.14 Apr 25, 2024
0.7.12 Apr 25, 2024
0.7.11 Apr 25, 2024
0.7.10 Apr 12, 2024
0.7.9 Apr 07, 2024
0.7.8 Apr 03, 2024
0.7.7 Apr 03, 2024
0.7.6 Apr 02, 2024
0.7.5 Mar 30, 2024
0.7.4 Mar 29, 2024
0.7.3 Mar 28, 2024
0.7.2 Mar 27, 2024
0.7.1 Mar 27, 2024
0.7.0 Mar 27, 2024
0.6.9 Mar 23, 2024
0.6.8 Mar 22, 2024
0.6.7 Mar 21, 2024
0.6.6 Mar 20, 2024
0.6.5 Mar 19, 2024
0.6.4 Mar 19, 2024
0.6.3 Mar 18, 2024
0.6.2 Mar 18, 2024
0.6.1 Mar 17, 2024
0.6.0 Mar 17, 2024
0.5.0 Mar 16, 2024
0.4.1 Mar 16, 2024
0.4.0 Mar 15, 2024
0.3.0 Mar 10, 2024
0.2.0 Feb 27, 2024
0.1.14 Feb 24, 2024
0.1.13 Feb 24, 2024
0.1.12 Feb 23, 2024
0.1.11 Feb 23, 2024
0.1.10 Feb 21, 2024
0.1.9 Feb 21, 2024
0.1.8 Feb 20, 2024
0.1.7 Feb 20, 2024
0.1.6 Feb 20, 2024

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies: