xarray-python

Guides writing, reviewing, and testing Xarray labeled N-dimensional array workflows in Python.

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill xarray-python-schattenspiegel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: xarray-python
Source: https://github.com/schattenspiegel/skill-foundry-skills/tree/main/skills/xarray-python
Command: npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill xarray-python-schattenspiegel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires xarray, numpy, pandas, pytest, and includes references (resource) components.

What problem does it solve? Xarray code often fails silently through coordinate misalignment, accidental data materialization, or incorrect weighted reductions. This Skill enforces explicit execution contracts for DataArray and Dataset workflows so alignment, indexing, reduction, and I/O behavior stay correct and verifiable. ## Core Features & Use Cases - Alignment and indexing contracts: Declare exact, inner, outer, left, or right join policy and choose between label-based .sel and position-based .isel selection before combining arrays. - Evaluated recipes with tests: Apply verified anchors for exact-aligned arithmetic, mask-aware weighted means, and daily time resampling, each paired with a pytest verification contract. - Lazy execution and I/O boundaries: Preserve Dask-backed laziness across chunked data and state NetCDF/Zarr round-trip requirements at storage boundaries. - Use Case: When computing a weighted time mean over observations with missing values, use the mask-aware weighted reduction recipe to normalize weights only over valid samples and reject zero effective weight with a precise error. ## Quick Start Ask the assistant to write or review an Xarray function that computes a weighted time mean with explicit alignment and missing-data handling, including its pytest verification.

Frequently Asked Questions about xarray-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent silent coordinate misalignment in Xarray arithmetic?▼

Use xr.align with join="exact" before arithmetic on independently sourced arrays so mismatched coordinates raise an error instead of producing a silent union. The exact-aligned arithmetic recipe demonstrates this pattern with a verification test.

How to compute a weighted mean in Xarray with missing values?▼

Align values and weights exactly, mask weights where values are null, then divide the weighted sum by the effective weight sum. Reject zero effective weight explicitly rather than returning a misleading result.

When should I use Xarray instead of pandas or NumPy?▼

Use Xarray for labeled N-dimensional data where coordinates drive alignment and selection. It is not appropriate for pandas-only tabular work or unlabeled NumPy arrays where dimension labels add no value.

Does Xarray support lazy evaluation with Dask?▼

Yes, Xarray wraps Dask arrays as lazy chunked arrays that build a deferred computation graph. Chunking and explicit .compute() boundaries control execution and memory, so compute only at a tested consumer boundary.

Why does Xarray resample fail on my time series?▼

Resampling requires a unique, monotonically increasing DatetimeIndex on the time dimension. Validate the index before resampling and raise a precise error for duplicate or unsorted timestamps rather than coercing them.