temporian.to_numpy #
to_numpy(
evset: EventSet,
timestamp_to_datetime: bool = True,
timestamps: bool = True,
) -> Dict[str, ndarray]
Converts an EventSet
to a flattened dictionary with
numpy arrays.
Usage example
>>> from datetime import datetime
>>> evset = tp.event_set(
... timestamps=['2023-11-08T17:14:38', '2023-11-29T21:44:46'],
... features={
... "store": ['STORE_1', 'STORE_2'],
... "revenue": [1571, 6101]
... },
... indexes=["store"],
... )
# Timestamps are exported as datetime64[s] if they were created as datetimes,
# otherwhise they are floats
>>> res = tp.to_numpy(evset)
>>> res
{'store': array([b'STORE_2', b'STORE_1'], dtype='|S7'), 'revenue': array([6101, 1571]),
'timestamp': array(['2023-11-29T21:44:46', '2023-11-08T17:14:38'], dtype='datetime64[s]')}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
evset |
EventSet
|
input event set. |
required |
timestamp_to_datetime |
bool
|
If true, cast Temporian timestamps to datetime64 when is_unix_timestamp is set to True. |
True
|
timestamps |
bool
|
If true, the timestamps are included as a column. |
True
|
Returns:
Type | Description |
---|---|
Dict[str, ndarray]
|
object with numpy arrays created from EventSet. |