pypi / narwhals
narwhals
What changed in narwhals 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-30.
11 breaking4 new APIs and options2 performance2 behavior and defaults1 tooling37 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initnarwhals 257 changes
Breaking changes 11
Returns null when no valid values exist.
Returns null when no valid values exist.
Mismatched items raise InvalidOperationError on pyarrow-backed backends.
Nulls are no longer dropped on pandas-like and Dask backends.
Consistently raises DuplicateError.
On Dask, var and std return null for N <= ddof and zero instead of null for constant group_by groups.
PyArrow cum_sum upcasts Int8, Int16, UInt8 and UInt16 inputs to Int64.
Floor division by zero returns null on pandas-like backends.
Invalid str.pad_start and str.pad_end arguments are rejected consistently across backends.
Negative offsets match Polars, and negative lengths raise an error.
Duplicate struct field names raise DuplicateError.
New APIs and options 4
Dask now supports list len, get, min, max, mean, median, sum, and sort operations.
DataFrame and LazyFrame gain a cast method for casting columns.
list.contains is supported for PyArrow, pandas and Dask.
Reader and scanner functions accept file-like objects.
Performance 2
Avoids copying NumPy arrays on pandas 3.
LazyFrame.cast no longer resolves the full schema just to check column names.
Behavior and default changes 2
Adds support for DuckDB 2.0 in joins, time zone lookup, and from_native typing.
Plugin support now extends to IO and from_* methods/functions.
Tooling 1
Narwhals hints at the narwhals-datafusion plugin when given a datafusion.DataFrame.
Fixes and other changes 37
Floor division on DuckDB is corrected for negative operands and floats.
Operations no longer raise an unhashable type error for cuDF categorical columns.
Corrects DuckDB duration results for durations of one hour or more.
Handles eager plugin native objects.
Handles eager plugin native objects.
Null handling in mode is fixed for SQL-like backends.
Modules that are still being imported are now ignored.
Scalar reduction results keep their dtype on the PyArrow backend.
Set difference between selectors is restored.
Selector union columns are returned in schema order.
Handles eager plugin native objects.
Invalid descending and reverse values raise consistent errors in sort and top_k.
Non-ASCII letters are treated as word characters on DuckDB, Spark-like, and old Polars backends.
Invalid descending and reverse values raise consistent errors in sort and top_k.
Corrects SQL backend results with ddof > 1, including over and null for N <= ddof.
Returns a numeric dtype for all-null object columns.
Counts characters rather than bytes on Polars < 2.0.
Casting to String preserves nulls on pandas before v3.0.0.
DuckDB diagonal concatenation uses the relations' own connection.
Boolean rendering aligns across pandas-like and Dask backends.
When ignore_nulls=True, pandas-like and Dask backends drop the trailing separator.
Behavior aligns with polars<0.20.6.
Scalar-only expressions are broadcast for SQL-like backends.
The PyArrow backend preserves all-null rows.
PySpark avoids DIVIDE_BY_ZERO for correlation on constant columns.
On pandas-like backends, cum_count(reverse=True) counts non-null values.
Dask aligns scalar operands before fill_null and horizontal reductions.
Pandas-like and PyArrow horizontal functions broadcast literals.
Null handling for list.contains on lazy backends now aligns with Polars.
Avoids name collisions for max_horizontal and min_horizontal on pandas-like backends.
Dask aligns series before fillna and isna in mean_horizontal.
__mod__ and __rmod__ behavior with negative operands aligns across backends.
PyArrow uses native starts_with and ends_with kernels, fixing empty-suffix ends_with.
str.replace(n=0) works on pandas-like backends.
A negative width is rejected consistently across backends.
str.zfill(0) works on PyArrow-backed data.
Corrects handling of plus-prefixed strings on polars<=1.30 and supports polars 0.20.4.