xarray-dataclass
xarray data creation by data classes
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and solves a real problem for teams working with xarray who want type safety and schema enforcement. It is well-suited for scientific computing and data-analysis workflows where consistency and static checking add value. No known vulnerabilities.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later; xarray and numpy must be installed.
- Low friction install with only three runtime dependencies (numpy, typing-extensions, xarray).
- Active maintenance as of August 2026 with recent commits.
License · maintenance · safety
permissive license (permissive) — MIT License permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you include the original copyright notice.
last release 2025-07-30 (380 days) · last repo commit 2026-08-10 · 11 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 78,169 downloads/mo, #14,465 on PyPI
Alternatives
Verify before relying
pip install xarray-dataclass
from dataclasses import dataclass
from typing import Literal
from xarray_dataclass import AsDataArray, Data, Coord
X, Y = Literal["x"], Literal["y"]
@dataclass
class Image(AsDataArray):
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
image = Image.new([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])- Whether static type checking with Pyright works as advertised for all dimension and dtype combinations.
- Performance characteristics when working with large multidimensional arrays compared to raw xarray.
- Compatibility with xarray's latest versions beyond what the dependency specification guarantees.
What it is and what it does
xarray-dataclass wraps xarray's DataArray and Dataset objects in a dataclass-based interface, letting you declare typed multidimensional data structures with fixed dimensions, coordinates, and attributes at definition time. Instead of building xarray objects imperatively with method calls, you define a dataclass using special type hints (Data, Coord, Attr, Name) that encode the structure, then instantiate it with `.new()` or NumPy-like factory methods (`.zeros()`, `.ones()`). The package validates that your data matches the declared schema and provides static type checking support through Pyright.
It is primarily useful for scientific and data-analysis workflows where you want to enforce a consistent structure across xarray objects—for example, ensuring all images in a batch have the same dimensions and dtype, or defining reusable templates for multidimensional datasets. The package depends on numpy, xarray, and typing-extensions; it is actively maintained and supports Python 3.9 through 3.13.
Use it for
- Define reusable typed templates for multidimensional scientific data (e.g., images, time series, gridded fields) with fixed dimensions and dtypes.
- Create xarray DataArrays or Datasets with static type checking to catch dimension/dtype mismatches at development time.
- Build batch processing pipelines where all inputs must conform to a declared schema (e.g., all images must be 2D float arrays with x and y coordinates).
- Attach metadata (attributes, coordinate names) to xarray objects declaratively rather than imperatively after creation.
- Generate xarray objects with NumPy-like constructors (zeros, ones) while enforcing the declared structure.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has low install friction, carries a permissive MIT license, and solves a real problem for teams working with xarray who want type safety and schema enforcement. It is well-suited for scientific computing and data-analysis workflows where consistency and static checking add value. No known vulnerabilities.
Install
xarray-dataclass on PyPI
Before you install
Low friction install with only three runtime dependencies (numpy, typing-extensions, xarray). Active maintenance as of August 2026 with recent commits.
Requires Python 3.9 or later; xarray and numpy must be installed.
License in practice
MIT License permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you include the original copyright notice.
Quickstart
pip install xarray-dataclass
from dataclasses import dataclass
from typing import Literal
from xarray_dataclass import AsDataArray, Data, Coord
X, Y = Literal["x"], Literal["y"]
@dataclass
class Image(AsDataArray):
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
image = Image.new([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])
Verify before relying
- Whether static type checking with Pyright works as advertised for all dimension and dtype combinations.
- Performance characteristics when working with large multidimensional arrays compared to raw xarray.
- Compatibility with xarray's latest versions beyond what the dependency specification guarantees.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesnumpytyping-extensionsxarray |
| Maintenance | Actively maintained 380 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 78,169 / month, #14,465 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9 |
Evidence: xarray_dataclass-3.0.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “typed xarray dataarray”
- xarray-dataclassDefines typed xarray DataArray and Dataset objects using Python…
- odc-loaderConstructs xarray objects from parsed geospatial metadata, enabling…
- sphinx-autosummary-accessorsA Sphinx extension that generates proper documentation for pandas or…
Give your agent the search over MCP, or paste the wish link into any chat.
More Scientific/Engineering packages
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
pandas provides fast, flexible data structures (Series and DataFrame) for loading, cleaning, transforming, and analyzing labeled or relational data in Python.
scipy provides numerical algorithms for mathematics, science, and engineering—including optimization, integration, linear algebra, Fourier transforms, signal and image processing, and ODE solvers—built on numpy arrays.
scikit-learn provides a comprehensive Python library for supervised and unsupervised machine learning, including classification, regression, clustering, dimensionality reduction, and model evaluation tools built on NumPy and SciPy.
Install it if you need to train, evaluate, or deploy supervised or unsupervised learning models.
dill extends Python's pickle module to serialize and deserialize a much wider range of Python objects, including functions, lambdas, classes, and interpreter sessions, to byte streams for storage or network transmission.
Multiprocess is an enhanced fork of Python's standard multiprocessing library that uses dill for better serialization, allowing you to spawn processes with a threading-like API and share complex objects between them.
Install it if you use multiprocessing and encounter pickle serialization limits with lambdas or complex objects.
See also pint-xarray · spatial_image · xarray · cf-xarray · multiscale-spatial-image · xproj · abstractcp · typed-json-dataclass · dataclass-csv · odc-loader