Skip to content

 zarr.load

zarr.load

load(
    store: StoreLike,
    path: str | None = None,
    zarr_format: ZarrFormat | None = None,
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]

Load data from an array or group into memory.

Parameters:

Returns:

  • out

    If the path contains an array, out will be a numpy array. If the path contains a group, out will be a dict-like object where keys are array names and values are numpy arrays.

See Also

save, savez, open

Notes

If loading data from a group of arrays, data will not be immediately loaded into memory. Rather, arrays will be loaded into memory as they are requested.

Unlike open, which returns a lazy Array or Group backed by the store, load eagerly reads the data and returns it as an in-memory array (or a dict of arrays for a group). The array type is NumPy by default, but follows the configured buffer prototype (for example, CuPy for GPU use cases). Use open when you want to read or write data incrementally without loading it all into memory.

Source code in zarr/api/synchronous.py
def load(
    store: StoreLike,
    path: str | None = None,
    zarr_format: ZarrFormat | None = None,
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
    """Load data from an array or group into memory.

    Parameters
    ----------
    store : StoreLike
        StoreLike object to open. See the
        [storage documentation in the user guide][user-guide-store-like]
        for a description of all valid StoreLike values.
    path : str or None, optional
        The path within the store from which to load.

    Returns
    -------
    out
        If the path contains an array, out will be a numpy array. If the path contains
        a group, out will be a dict-like object where keys are array names and values
        are numpy arrays.

    See Also
    --------
    save, savez, open

    Notes
    -----
    If loading data from a group of arrays, data will not be immediately loaded into
    memory. Rather, arrays will be loaded into memory as they are requested.

    Unlike [`open`][zarr.open], which returns a lazy [`Array`][zarr.Array] or
    [`Group`][zarr.Group] backed by the store, `load` eagerly reads the data and
    returns it as an in-memory array (or a dict of arrays for a group).
    The array type is NumPy by default, but follows the configured
    buffer prototype (for example, CuPy for GPU use cases).
    Use `open` when you want to read or write data incrementally without loading it
    all into memory.
    """
    return sync(async_api.load(store=store, zarr_format=zarr_format, path=path))