Skip to content

temporian.from_struct #

from_struct(
    data: List[Tuple[Dict[str, Any], Dict[str, DataArray]]],
    timestamps: str = "timestamp",
    is_unix_timestamp: bool = False,
) -> EventSet

Creates an EventSet from indexed data.

Unlike event_set, from_struct expects for the data to be already split by index value. Supported values for timestamps, indexes, and features as similar to event_set.

Usage examples:

```python
>>> evset = tp.from_struct(
...    [
...        (
...            {"i1": 1, "i2": "A"},
...            {"timestamp": [1, 2], "f1": [10, 11], "f2": ["X", "Y"]},
...        ),
...        (
...            {"i1": 1, "i2": "B"},
...            {"timestamp": [3, 4], "f1": [12, 13], "f2": ["X", "X"]},
...        ),
...    ])

```

Parameters:

Name Type Description Default
data List[Tuple[Dict[str, Any], Dict[str, DataArray]]]

Indexed data.

required
timestamps str

Name of the feature to be used as timestamps for the EventSet.

'timestamp'
is_unix_timestamp bool

Whether the timestamps correspond to unix time. Unix times are required for calendar operators. If None (default), timestamps are interpreted as unix times if the timestamps argument is an array of date or date-like object.

False

Returns:

Type Description
EventSet

An EventSet.