Stats, linear algebra and einops for xarray
Maintained. Last release 4 months ago, commits in 5 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install xarray-einstatsxarray-einstats
Stats, linear algebra and einops for xarray
Installation
To install, run
(.venv) $ pip install xarray-einstats
See the docs for more extensive install instructions.
Overview
As stated in their website:
xarray makes working with multi-dimensional labeled arrays simple, efficient and fun!
The code is often more verbose, but it is generally because it is clearer and thus less error prone and more intuitive. Here are some examples of such trade-off where we believe the increased clarity is worth the extra characters:
| numpy | xarray |
|---|---|
a[2, 5] | da.sel(drug="paracetamol", subject=5) |
a.mean(axis=(0, 1)) | da.mean(dim=("chain", "draw")) |
a.reshape((-1, 10)) | da.stack(sample=("chain", "draw")) |
a.transpose(2, 0, 1) | da.transpose("drug", "chain", "draw") |
In some other cases however, using xarray can result in overly verbose code that often also becomes less clear. provides wrappers around some numpy and scipy functions (mostly and ) and around with an api and features adapted to xarray. Continue at the .