Available languages: [Python](https://databento.com/docs/api-historical/helpers/dbn-store-to-ndarray.python.md) · [C++](https://databento.com/docs/api-historical/helpers/dbn-store-to-ndarray.cpp.md) · [Rust](https://databento.com/docs/api-historical/helpers/dbn-store-to-ndarray.rust.md) · [HTTP](https://databento.com/docs/api-historical/helpers/dbn-store-to-ndarray.http.md)

Source: https://databento.com/docs/api-historical/helpers/dbn-store-to-ndarray


### DBNStore.to_ndarray

Converts data to a [numpy](https://numpy.org/) N-dimensional array. Each element
will contain a Python representation of the binary fields as a `Tuple`.

#### API method

```python
DBNStore.to_ndarray(
    schema: Schema | str | None = None,
    count: int | None = None,
) -> np.ndarray | NDArrayIterator
```

#### Parameters

| Parameter | Type | Required | Description |
| `schema` | Schema or str | optional | The data record [schema](https://databento.com/docs/schemas/whats-a-schema.md) for the output array. Must be one of the values from [list_schemas](https://databento.com/docs/api-historical/metadata/metadata-list-schemas.md). This is only required when reading a `DBNStore` with mixed record types. |
| `count` | int | optional | If set, instead of returning a single `np.ndarray` a `NDArrayIterator` instance will be returned. When iterated, this object will yield a `np.ndarray` with at most `count` elements until the entire contents of the `DBNStore` are exhausted. |

#### Returns

A [numpy.ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html) object.

#### Example usage

```python
import databento as db

client = db.Historical("$YOUR_API_KEY")

data = client.timeseries.get_range(
    dataset="GLBX.MDP3",
    symbols=["ESM2"],
    start="2022-06-06",
)

array = data.to_ndarray()
print(array[0].item())
```
#### Example response

```plaintext
(12,
0,
1,
3403,
1654473600070033767,
4108500000000,
1,
b'T',
b'A',
0,
0,
1654473600070314216,
18681,
157862)
```
