Skip to content

temporian.event_set #

event_set(
    timestamps: DataArray,
    features: Optional[Dict[str, DataArray]] = None,
    indexes: Optional[List[str]] = None,
    name: Optional[str] = None,
    is_unix_timestamp: Optional[bool] = None,
    same_sampling_as: Optional[EventSet] = None,
) -> EventSet

Creates an EventSet from arrays (lists, NumPy arrays, Pandas Series.)

Usage examples:

```python
>>> # Creates an EventSet with 4 timestamps and 3 features.
>>> evset = tp.event_set(
...     timestamps=[1, 2, 3, 4],
...     features={
...         "feature_1": [0.5, 0.6, np.nan, 0.9],
...         "feature_2": ["red", "blue", "red", "blue"],
...         "feature_3": [10, -1, 5, 5],
...     },
... )

>>> # Creates an EventSet with an index.
>>> evset = tp.event_set(
...     timestamps=[1, 2, 3, 4],
...     features={
...         "feature_1": [0.5, 0.6, np.nan, 0.9],
...         "feature_2": ["red", "blue", "red", "blue"],
...     },
...     indexes=["feature_2"],
... )

>>> # Create an EventSet with datetimes.
>>> from datetime import datetime
>>> evset = tp.event_set(
...     timestamps=[datetime(2015, 1, 1), datetime(2015, 1, 2)],
...     features={
...         "feature_1": [0.5, 0.6],
...         "feature_2": ["red", "blue"],
...     },
...     indexes=["feature_2"],
... )

```

Supported values for timestamps:

  • List of int, float, str, bytes and datetime.
  • Numpy arrays of int{32, 64}, float{32, 64}, str_, string_ / bytes_, Numpy datetime64, and object containing "str".
  • Pandas series of int{32, 64}, float{32, 64}, Pandas Timestamp.

String timestamps are interpreted as ISO 8601 datetime.

Supported values for features:

  • List of int, float, str, bytes, bool, and datetime.
  • Numpy arrays of int{32, 64}, float{32, 64}, str_, string_ / bytes_, Numpy datetime64, or object containing "str".
  • Pandas series of int{32, 64}, float{32, 64}, Pandas Timestamp.

Date / datetime features are converted to int64 unix times. NaN for float-like features are interpreted as missing values.

Parameters:

Name Type Description Default
timestamps DataArray

Array of timestamps values.

required
features Optional[Dict[str, DataArray]]

Dictionary of feature names to feature values. Feature and timestamp arrays must be of the same length.

None
indexes Optional[List[str]]

Names of the features to use as indexes. If empty (default), the data is not indexed. Only integer and string features can be used as indexes.

None
name Optional[str]

Optional name of the EventSet. Used for debugging, and graph serialization.

None
is_unix_timestamp Optional[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.

None
same_sampling_as Optional[EventSet]

If set, the new EventSet is checked and tagged as having the same sampling as same_sampling_as. Some operators, such as EventSet.filter(), require their inputs to have the same sampling.

None

Returns:

Type Description
EventSet

An EventSet.