nd-arrow-array (Python)
Python bindings for the nd_arrow.array Arrow extension type.
The PyPI package is nd-arrow-array. The import name is nd_arrow_array.
The bindings move N-dimensional arrays between NumPy, pyarrow and the
format in FORMAT.md.
Install
pip install nd-arrow-array # NumPy only
pip install nd-arrow-array[arrow] # with pyarrow
pip install nd-arrow-array[xarray] # with xarray and cftime
To build from source, run pip install maturin and maturin develop in this directory.
Classes
| Class | Content |
|---|---|
NdArray |
One array: values, named dimensions, attributes. |
NdColumn |
An Arrow column. Each row is one NdArray or None. |
NdRecordBatch |
Named arrays on one shared grid, with global attributes. |
Example
import numpy as np
import nd_arrow_array as nda
a = nda.NdArray.from_numpy(
np.arange(6.0).reshape(2, 3),
dims=["time", "lat"],
attrs={"units": "K", "valid_range": np.array([0, 400], dtype="float32")},
)
a.sizes # {'time': 2, 'lat': 3}
a.set_attr("long_name", "sea surface temperature")
a.to_numpy()
col = nda.NdColumn.from_arrays([a, None])
arr = col.to_arrow() # pyarrow array
nda.NdColumn.from_arrow(arr)[0] == a # True
pyarrow
pip install nd-arrow-array[arrow] adds pyarrow. pyarrow sees an nd column as a
struct column. The field metadata ARROW:extension:name = nd_arrow.array
marks it as an nd column. See FORMAT.md.
Arrays and columns
import pyarrow as pa
# An array from flat pyarrow values in C order.
a = nda.NdArray(pa.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]),
dims={"time": 2, "lat": 3}, attrs={"units": "K"})
a.values # the flat values as a pyarrow.Array
col = nda.NdColumn.from_arrays([a, None])
arr = col.to_arrow() # pyarrow.StructArray, one row per array
nda.NdColumn.from_arrow(arr) # back to an NdColumn
pa.field(col).metadata # the extension name and version
Record batches and tables
lat = nda.NdArray.from_numpy(np.array([-10.0, 0.0, 10.0]), dims=["lat"])
batch = nda.NdRecordBatch({"sst": a, "lat": lat}, attrs={"title": "demo"})
rb = batch.to_arrow() # pyarrow.RecordBatch with one row
table = pa.table(batch) # pyarrow.Table, through the PyCapsule interface
# Many batches with one schema: one row each.
rows = nda.encode_batches([batch, other_batch])
batches = nda.NdRecordBatch.from_arrow(rows) # a list, one NdRecordBatch per row
NdRecordBatch.from_arrow accepts a RecordBatch, a Table or a
RecordBatchReader. It returns one NdRecordBatch for each row.
The global attributes travel in the __global_attrs__ column.
Files
Parquet and Arrow IPC keep the field metadata, so the nd columns survive a write and a read:
import pyarrow.parquet as pq
pq.write_table(pa.Table.from_batches([rows]), "data.parquet")
batches = nda.NdRecordBatch.from_arrow(pq.read_table("data.parquet"))
with pa.OSFile("data.arrow", "wb") as sink, pa.ipc.new_file(sink, rows.schema) as writer:
writer.write_batch(rows)
with pa.memory_map("data.arrow") as source:
batches = nda.NdRecordBatch.from_arrow(pa.ipc.open_file(source).read_all())
Other libraries
NdArray, NdColumn and NdRecordBatch implement the Arrow PyCapsule
interface (__arrow_c_array__, __arrow_c_stream__, __arrow_c_schema__).
pyarrow, polars, DuckDB and other Arrow libraries read them without a copy,
for example pa.array(col) or pa.table(batch).
xarray
pip install nd-arrow-array[xarray] adds xarray and cftime.
import xarray as xr
ds = xr.Dataset(
{"air": (("time", "lat"), np.zeros((2, 3)), {"units": "K"})},
coords={"time": np.array(["2020-01-01", "2020-01-02"], "datetime64[ns]"),
"lat": [-10.0, 0.0, 10.0]},
)
batch = nda.NdRecordBatch.from_xarray(ds) # all variables and coordinates
batch.to_xarray() # an xarray.Dataset
a = nda.NdArray.from_xarray(ds["air"]) # values, dims and attrs only
a.to_xarray(name="air") # an xarray.DataArray
NdRecordBatch.from_xarrayaccepts aDatasetor aDataArray. Each variable and each coordinate becomes a column.- A 1-D column with the name of its dimension becomes an index coordinate.
- Other coordinates go into the CF
coordinatesattribute of the data variables. A coordinate that no data variable uses goes into thecoordinatesattribute of the batch. NdArray.from_xarraydoes not keep coordinates.- In
to_xarray, nulls becomeNaNorNaT. Integer and bool arrays with nulls becomefloat64, as in xarray CF decoding. - Object arrays must hold
stror cftime dates.NoneandNaNbecome nulls. - cftime dates become
timestamp[us]in the standard calendar:standard,gregorian,proleptic_gregorianandjuliankeep the exact instant;noleap,365_day,all_leap,366_dayand360_daykeep the year, month, day and time. A date that the standard calendar does not have, such as 30 February, raisesValueError. Useconvert_calendar(..., align_on="date")in xarray first.
Rules
- NumPy dtypes:
bool, signed and unsigned integers,float16,float32,float64,datetime64andtimedelta64(s,ms,us,ns) andstr. Other dtypes raiseTypeError. - A
numpy.ma.MaskedArraymask andNaTbecome nulls.NaNstays a value. to_numpy()returns aMaskedArraywhen the values have nulls.attrsreturns a copy. Assign a new dict, or useset_attranddel_attr.- All classes implement the Arrow PyCapsule interface, so pyarrow, polars and DuckDB can read them.
- The package ships type stubs (
py.typed), so mypy and pyright check calls.
Test
pip install pytest mypy numpy pyarrow xarray cftime
maturin develop && pytest
python -m mypy.stubtest nd_arrow_array # stubs match the module
mypy --strict --warn-unused-ignores tests/typing
Metadata
Release files for nd-arrow-array 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nd_arrow_array-0.5.0.tar.gz | 196.6 kB | With provenance | Details for nd_arrow_array-0.5.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| nd_arrow_array-0.5.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for nd_arrow_array-0.5.0-cp39-abi3-win_amd64.whl |
| nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| nd_arrow_array-0.5.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for nd_arrow_array-0.5.0-cp39-abi3-macosx_11_0_arm64.whl |
| nd_arrow_array-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for nd_arrow_array-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 15.5 MB
Release files / nd_arrow_array-0.5.0.tar.gz
| Download URL | nd_arrow_array-0.5.0.tar.gz |
|---|---|
| Size | 196.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83ffafb7cc0b70faca206120122d456faef8fe610d59fa931261af0951bf5717
|
|
BLAKE2b-256 checksum How to use checksums |
782d1c558827019b7dca6c6940d79c5a830d14cd6364d43d025241ba6ec805ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / nd_arrow_array-0.5.0-cp39-abi3-win_amd64.whl
| Download URL | nd_arrow_array-0.5.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 2.9 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
02717afe14bdb8bf869d4902709c0a14de63345c28ab4b0b628d359e3dd3cbae
|
|
BLAKE2b-256 checksum How to use checksums |
094d5685a1ce77ca8d9c6e3707b283eb84ee3e41ad6625f10320616297aa8f1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b8b2b1c41ed9160d5037affac2f7603cbe3bb8478456a3cc06bfb51d618a8bed
|
|
BLAKE2b-256 checksum How to use checksums |
4c29dd0fe7be053d12f94b21e27fad4d40529363a89c929195a6444907003760
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | nd_arrow_array-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
6c61c79e5f48a9cfe6c6a5984bf385abbef0195396a89be6e76878a6138abc1b
|
|
BLAKE2b-256 checksum How to use checksums |
96d05b410c13f824ac5e6f29e8baa90d13d78e551a314167272ad000449c7b38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / nd_arrow_array-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | nd_arrow_array-0.5.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1c8a0b33eeadb1cdce5ca97946256f76a3daf59343bebca49bec114809292e36
|
|
BLAKE2b-256 checksum How to use checksums |
0b8e030fc754b2deb283d7da1280ee2efdeabe5299c47c1aa7500269ac7a53e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / nd_arrow_array-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | nd_arrow_array-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
1468b7048fea86975580766fa5ae9f67d2d94f5aa1fbda08b2dae2396502c13c
|
|
BLAKE2b-256 checksum How to use checksums |
977ee6a956ce9a90cbe2823ba3812e92bc2b3d2a6d58411f728245d574259a09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for nd-arrow-array 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for nd_arrow_array-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.