DBNStore.to_ndarray
Converts data to a numpy N-dimensional array. Each element will contain a Python representation of the binary fields as a Tuple.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
schema | Schema or str | optional | The data record schema for the output array. Must be one of the values from list_schemas. 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 object.
API method
1 2 3 4
DBNStore.to_ndarray(
schema: Schema | str | None = None,
count: int | None = None,
) -> np.ndarray | NDArrayIterator Example usage
1 2 3 4 5 6 7 8 9 10 11 12
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14
(12, 0, 1, 3403, 1654473600070033767, 4108500000000, 1, b'T', b'A', 0, 0, 1654473600070314216, 18681, 157862)