# dask.array.to_npy_stack

### dask.array.to_npy_stack(dirname, x, axis=0)

Write dask array to a stack of .npy files

This partitions the dask.array along one axis and stores each block along
that axis as a single .npy file in the specified directory

#### WARNING
This format uses the [`pickle`](https://docs.python.org/3/library/pickle.html#module-pickle) module to serialize array metadata.
The `pickle` module is not secure. Only load .npy stacks you trust.

#### SEE ALSO
[`from_npy_stack`](dask.array.from_npy_stack.html.md#dask.array.from_npy_stack)

### Examples

```pycon
>>> x = da.ones((5, 10, 10), chunks=(2, 4, 4))
>>> da.to_npy_stack('data/', x, axis=0)
```

The `.npy` files store numpy arrays for `x[0:2], x[2:4], and x[4:5]`
respectively, as is specified by the chunk size along the zeroth axis:

```default
$ tree data/
data/
|-- 0.npy
|-- 1.npy
|-- 2.npy
|-- info
```

The `info` file stores the dtype, chunks, and axis information of the array.
You can load these stacks with the [`dask.array.from_npy_stack()`](dask.array.from_npy_stack.html.md#dask.array.from_npy_stack) function.

```pycon
>>> y = da.from_npy_stack('data/')
```

<!-- !! processed by numpydoc !! -->
