← notebooks

A tiny labeled array

This page starts life as a standard .ipynb file. Quarto executes it and writes Hugo-compatible Markdown, so the output stays readable without a Jupyter server.

import numpy as np
import xarray as xr

da = xr.DataArray(
    np.arange(6).reshape(2, 3),
    dims=("y", "x"),
    coords={"y": [10, 20], "x": [1, 2, 3]},
    name="value",
)
print(da)
<xarray.DataArray 'value' (y: 2, x: 3)> Size: 48B
array([[0, 1, 2],
       [3, 4, 5]])
Coordinates:
  * y        (y) int64 16B 10 20
  * x        (x) int64 24B 1 2 3
print(f"mean = {da.mean().item():.1f}")
mean = 2.5

/comments