Skip to main content

narwhals-datafusion

CI compat PyPI version PEP 740 Downloads

Apache DataFusion backend for Narwhals, registered through the narwhals.plugins entry point.

pip install narwhals-datafusion                    # core
pip install "narwhals-datafusion[extra-functions]" # + mode, skew, kurtosis

Usage

import narwhals as nw
import pyarrow as pa
from datafusion import SessionContext

ctx = SessionContext()
df = ctx.from_arrow(pa.table({"a": [1, 2, 3], "b": ["x", "y", "x"]}))

lf = nw.from_native(df)  # nw.LazyFrame on this backend
result = (
    lf.group_by("b")
    .agg(nw.col("a").sum())
    .sort("b")
    .collect(backend="pyarrow")
)

Everything is lazy until .collect(): expressions become datafusion.Expr, frame verbs become datafusion.DataFrame methods, and DataFusion executes the plan. Dtypes are pyarrow end-to-end. A longer tour, extra included: docs/playground.ipynb.

Used by

  • pandera: pip install 'pandera[datafusion]' validates datafusion.DataFrame through this plugin. tests/pandera/ pins the narwhals.stable.v1 calls it makes.

Compatibility

  • Python >=3.10; tested on 3.12.
  • datafusion>=54,<55: capped at the tested major; a release moves the cap.
  • narwhals>=2.27: floor only; tested on 2.27, the narwhals/ submodule.
  • datafusion-extra-functions-ffi>=0.1 (extra): each shim minor pins its datafusion major.
  • Weekly, compat.yml (the badge): both suites on the newest narwhals release inside the datafusion cap, extra included.

Architecture

A subclass of narwhals' SQL layer (narwhals._sql, narwhals._compliant), the layer DuckDB, Ibis and Spark also use.

Module Class
dataframe.py DataFusionLazyFrame: frame verbs over datafusion.DataFrame
expr.py DataFusionExpr: the SQLExpr hooks, aggregates, windows, casts
namespace.py DataFusionNamespace: SQLNamespace primitives, IO, horizontal functions
group_by.py, selectors.py, expr_str/dt/list/struct.py supporting surface
utils.py function-name remapping, window/sort builders, dtype bridge via narwhals._arrow

API coverage

narwhals 2.27 on datafusion 54. ⚠️ entries work with the caveat in parentheses.

Namespace ✅ Supported ⚠️ Partial ❌ Not supported
Expr abs alias all any any_value ceil clip cos count cum_count cum_max cum_min cum_sum diff exp fill_nan first floor is_between is_close is_duplicated is_finite is_first_distinct is_in is_last_distinct is_nan is_null is_unique last len log max mean median min null_count over pipe rank rolling_mean rolling_std rolling_sum rolling_var round shift sin sqrt std sum var cast (no Enum) · fill_null (no strategy + limit) · kurtosis ([extra-functions] extra) · mode ([extra-functions] extra, keep="any" only) · n_unique (not over windows) · replace_strict (explicit default required) · skew ([extra-functions] extra) cum_prod quantile
Expr.str contains ends_with head len_chars pad_end pad_start replace_all slice split starts_with strip_chars strip_chars_end strip_chars_start tail to_date to_lowercase to_time to_uppercase zfill to_datetime (explicit format required) · to_titlecase (no word breaks on digits) replace (use replace_all)
Expr.dt convert_time_zone date day hour microsecond millisecond minute month nanosecond ordinal_day second to_string truncate weekday year replace_time_zone (None/"UTC" only) offset_by timestamp total_microseconds total_milliseconds total_minutes total_nanoseconds total_seconds
Expr.list contains get len max min sort unique (maintain_order=False only) mean median sum
Expr.struct field
LazyFrame collect collect_schema drop drop_nulls filter group_by head join rename select sort top_k unique unpivot with_columns with_row_index explode (single column) · sink_parquet (file path only) join_asof

Known limitations

  • mode, skew and kurtosis need the extra-functions extra. It installs datafusion-extra-functions-ffi, a prebuilt wheel of the datafusion-extra-functions crate. Without it the three raise NotImplementedError.
  • Not in the table: Expr.ewm_mean, Expr.map_batches, LazyFrame.tail, LazyFrame.gather_every: narwhals does not support them on lazy frames. Expr.filter, Expr.drop_nulls, Expr.unique: narwhals' SQL layer does not support them.
  • Row order is guaranteed only after sort; concat may interleave inputs.
  • nw.scan_csv/nw.scan_parquet cannot dispatch to a plugin yet (narwhals gap); read with a SessionContext and pass the frame to nw.from_native.

Metadata

Release files for narwhals-datafusion 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for narwhals-datafusion 0.1.6
File Size Uploaded
narwhals_datafusion-0.1.6.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for narwhals-datafusion 0.1.6
File Interpreter ABI Platform
narwhals_datafusion-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 55.6 kB

Release files / narwhals_datafusion-0.1.6.tar.gz

Download URL narwhals_datafusion-0.1.6.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fdd4b704985c53e3f58dbd77f268675b6be4f550b1a527c689c0a55b838c5b48
BLAKE2b-256 checksum
How to use checksums
a4d1079b932432dafde5505952ccf0944572f3c2b9fff7f7bff4e31213eedfea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / narwhals_datafusion-0.1.6-py3-none-any.whl

Download URL narwhals_datafusion-0.1.6-py3-none-any.whl
Size 29.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df5f014ba8437a1e36269e408c28ff0f4caf8324d4a524f3e644ce7edf1ac044
BLAKE2b-256 checksum
How to use checksums
ea3d82481b8c07c05672c0698934f6c1fdec8ea2775b3351748a99064e3a37d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page