Registry / data / dask-expr

dask-expr

JSON →
library2.0.0pypypi✓ verified 49d ago

Dask-expr provides a high-level expression system for Dask DataFrames, focusing on query optimization and improved organization. It became the default backend for `dask.dataframe` since Dask version 2024.3.0. The library, currently at version 2.0.0 (released January 21, 2025), is primarily maintained as part of the main Dask project, with its separate GitHub repository no longer actively maintained.

data
pip install dask-expr
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.930 runs
installs and imports cleanly · install 0.0s · import 0.493s · 37MB
glibc
py 3.103.930 runs
installs and imports cleanly · install 5.4s · import 0.450s · 38MB
98MB installed
● package 98MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dask_expr
import dask_expr as dx
While functional, dask-expr is now the default backend for dask.dataframe. It is often not explicitly imported for basic DataFrame operations.
dask.dataframe
import dask.dataframe as dd
The expression system is implicitly used when working with dask.dataframe since Dask 2024.3.0.

This quickstart demonstrates how to use Dask DataFrame, which leverages the dask-expr expression system internally for query optimization since Dask version 2024.3.0. No explicit `dask_expr` import is typically needed for standard DataFrame operations.

import dask.dataframe as dd # Create a Dask DataFrame (internally uses the dask-expr system) df = dd.from_dict({'a': range(1000), 'b': [f'cat_{i%5}' for i in range(1000)]}, npartitions=4) # Perform some operations result = df.groupby('b')['a'].mean() # Compute the result print(result.compute()) # To see the optimized query plan (requires graphviz to be installed) # try: # df.optimize().explain() # except ImportError: # print("Install graphviz to visualize the query plan: pip install 'graphviz'")
Debug
Known issues
breakingThe `dask-expr` library, particularly versions 0.5.1 and above, requires `pandas>=2`. This can lead to dependency conflicts if other libraries in your environment pin `pandas` to an older version (e.g., `<2`).
fix
Ensure all dependencies are compatible with `pandas>=2`. You may need to upgrade or constrain other libraries if conflicts arise. Consider using isolated environments (conda, virtualenv) for different projects.
affects: >=0.5.1
gotchaThe `dask-expr` GitHub repository is no longer actively maintained, as its implementation has been moved into the main `dask/dask` repository and it's now the default backend for `dask.dataframe`. While the PyPI package still exists, new development and core maintenance happen within the Dask project itself.
fix
For contributions or detailed technical understanding, refer to the Dask main repository and documentation, specifically the `dask.dataframe` sections. Continue to install `dask-expr` if your Dask version is older than 2024.3.0 and you wish to use the query planning features. Otherwise, it is installed by default with recent Dask versions.
affects: All versions
gotchaUsing `df.persist()` with the dask-expr query optimizer can sometimes block optimizations like projection or filter pushdown into the I/O layer.
fix
Use `persist()` sparingly and only when absolutely necessary, or when the full dataset is genuinely needed for subsequent complex operations. Re-evaluate if `persist()` is truly required, as the optimizer often handles intermediate computations efficiently without explicit persistence.
affects: All versions where dask-expr is enabled
gotchaDask-expr does not currently support 'named GroupBy Aggregations', which is a feature available in the legacy Dask DataFrame API.
fix
If 'named GroupBy Aggregations' are critical for your workflow, you might need to structure your aggregations differently (e.g., performing multiple individual aggregations and then combining them) or temporarily opt-out of the dask-expr backend if using an older Dask version where it wasn't the default (`dask.config.set({'dataframe.query-planning': False})`).
affects: All versions where dask-expr is enabled
breakingDask (and by extension, `dask.dataframe`) has `numpy` as a fundamental dependency. If `numpy` is not installed, importing `dask.dataframe` will fail with an `ImportError`.
fix
Ensure `numpy` is installed in your environment. It is typically installed as a dependency when installing `dask` or `dask[array]`. You can explicitly install it via `pip install numpy` or `conda install numpy`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'dask_expr'
`dask-expr` is not installed in the environment. Even though `dask.dataframe` became the default backend for `dask-expr` in Dask 2024.3.0, it still needs to be explicitly installed as a separate package if not pulled by `dask[dataframe]` installation.
fix
Install `dask-expr` using `pip install dask-expr` or ensure a comprehensive Dask installation with `pip install "dask[dataframe]"` or `conda install dask-expr -c conda-forge`.
ModuleNotFoundError: No module named 'dask_expr.io'
This error often occurs when using `dask-sql` or other dependent libraries with newer versions of Dask and `dask-expr`. It indicates that these libraries are trying to import a module (`dask_expr.io`) that has been moved, removed, or has changed its internal structure, leading to compatibility issues.
fix
This is typically a compatibility issue between `dask-sql` (or another library) and the current `dask` / `dask-expr` versions. Check the documentation or GitHub issues for `dask-sql` (or the relevant library) for updated compatibility information or try installing a specific older version of `dask-sql` that is known to be compatible with your Dask/dask-expr setup.
AttributeError: 'Min' object has no attribute 'dtype'
This `AttributeError` (or similar ones indicating an unsupported API function) means you are using a Dask DataFrame API method or attribute that is not yet fully implemented or has different behavior under the `dask-expr` backend.
fix
Consult the `dask-expr` API coverage documentation (often linked in the error message itself) to confirm support for the specific function. If it's not supported, consider refactoring your code to use alternative, supported operations. As a temporary workaround, you can disable `dask-expr` query planning with `import dask; dask.config.set({'dataframe.query-planning': False})`.
DeprecationWarning: The current Dask DataFrame implementation is deprecated.
This warning signals that the legacy Dask DataFrame backend is being replaced by `dask-expr`. It appears when `dask.dataframe` is imported, prompting users to install `dask-expr` and enable query planning to transition to the new, optimized backend.
fix
To enable the new backend and remove the warning, install `dask-expr` (`pip install dask-expr` or `pip install "dask[dataframe]"`) and explicitly enable query planning: `import dask; dask.config.set({'dataframe.query-planning': True})`. If you wish to suppress the warning without transitioning immediately, use `dask.config.set({'dataframe.query-planning-warning': False})`.
Upgrade
Version history
2.0.0latest on PyPI
Audit
Dependencies
daskrequiredCore Dask functionality, dask-expr is the default backend for dask.dataframe.
pandasrequiredDask-expr requires pandas version 2.0 or higher.
pyarrowoptionalOften used for efficient data interchange and I/O with Parquet files.
fsspecoptionalFor reading/writing from various file systems (e.g., S3, GCS).
Agent activity
65 hits · last 30 days
node
4
seranking-bot
4
ahrefsbot
2
amazonbot
1
Resources