github unionai-oss/pandera v0.31.0
v0.31.0: Validate Xarray DataArray, Dataset, and DataTree

10 hours ago

⭐️ Highlights

This is the release for all of you geospatial and multidimensional array-handling folks out there.

xarray support

Pandera now provides full support for xarray 🚀

Write a DatasetSchema with the object-based API

import numpy as np
import xarray as xr
import pandera.xarray as pa

schema = pa.DatasetSchema(
    data_vars={
        "temperature": pa.DataVar(dtype=np.float64, dims=("x", "y")),
        "pressure": pa.DataVar(dtype=np.float64, dims=("x", "y")),
    },
    coords={"x": pa.Coordinate(dtype=np.float64)},
)

ds = xr.Dataset(
    {
        "temperature": (("x", "y"), np.random.rand(3, 4)),
        "pressure": (("x", "y"), np.random.rand(3, 4)),
    },
    coords={"x": np.arange(3, dtype=np.float64)},
)
schema.validate(ds)

Or a DatasetModel with the class-based API:

from pandera.typing.xarray import Coordinate

class Surface(pa.DatasetModel):
    temperature: np.float64 = pa.Field(dims=("x", "y"))
    pressure: np.float64 = pa.Field(dims=("x", "y"))
    x: Coordinate[np.float64]

Surface.validate(ds)

First-class geopandas support

This release also adds first-class GeoDataFrameSchema and GeoDataFrameModel APIs for geopandas: https://pandera.readthedocs.io/en/latest/geopandas.html

What's Changed

New Contributors

Full Changelog: v0.30.1...v0.31.0

Don't miss a new pandera release

NewReleases is sending notifications on new releases.