temporian.EventSet.drop_index #
drop_index(
indexes: Optional[Union[str, List[str]]] = None,
keep: bool = True,
) -> EventSetOrNode
Removes indexes from an EventSet
.
Usage example
>>> a = tp.event_set(
... timestamps=[1, 2, 1, 0, 1, 1],
... features={
... "f1": [1, 1, 1, 2, 2, 2],
... "f2": [1, 1, 2, 1, 1, 2],
... "f3": [1, 1, 1, 1, 1, 1]
... },
... indexes=["f1", "f2"]
... )
>>> # Both f1 and f2 are indices
>>> a
indexes: [('f1', int64), ('f2', int64)]
features: [('f3', int64)]
events:
f1=1 f2=1 (2 events):
timestamps: [1. 2.]
'f3': [1 1]
f1=1 f2=2 (1 events):
timestamps: [1.]
'f3': [1]
f1=2 f2=1 (2 events):
timestamps: [0. 1.]
'f3': [1 1]
f1=2 f2=2 (1 events):
timestamps: [1.]
'f3': [1]
...
>>> # Drop "f2", remove it from features
>>> b = a.drop_index("f2", keep=False)
>>> b
indexes: [('f1', int64)]
features: [('f3', int64)]
events:
f1=1 (3 events):
timestamps: [1. 1. 2.]
'f3': [1 1 1]
f1=2 (3 events):
timestamps: [0. 1. 1.]
'f3': [1 1 1]
...
>>> # Drop both indices, keep them as features
>>> b = a.drop_index(["f2", "f1"])
>>> b
indexes: []
features: [('f3', int64), ('f2', int64), ('f1', int64)]
events:
(6 events):
timestamps: [0. 1. 1. 1. 1. 2.]
'f3': [1 1 1 1 1 1]
'f2': [2 1 1 2 2 1]
'f1': [1 2 1 2 1 1]
...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indexes |
Optional[Union[str, List[str]]]
|
Index column(s) to be removed from the input. This can be a
single column name ( |
None
|
keep |
bool
|
Flag indicating whether the removed indexes should be kept
as features in the output EventSet. Defaults to |
True
|
Returns:
Type | Description |
---|---|
EventSetOrNode
|
EventSet with the specified indexes removed. If |
EventSetOrNode
|
|
Raises:
Type | Description |
---|---|
ValueError
|
If an empty list is provided as the |
KeyError
|
If any of the specified |
ValueError
|
If a feature name coming from the indexes already exists in
the input, and the |