temporian.EventSet.rename #
rename(
features: Optional[
Union[str, Dict[str, str], List[str]]
] = None,
indexes: Optional[
Union[str, Dict[str, str], List[str]]
] = None,
) -> EventSetOrNode
Renames an EventSet
's features and index.
If the input has a single feature, then the features
can be a
single string with the new name.
If the input has multiple features, then features
can either be (1) a
dictionary mapping old names to the new names, or (2) a list of new
names of the same size as evtset.schema.feature_names()
.
The indexes renaming follows the same criteria, accepting a single string, a mapping, or a list.
Usage example
>>> a = tp.event_set(
... timestamps=[0, 1],
... features={"f1": [0, 2], "f2": [5, 6]}
... )
>>> b = 5 * a
>>> # Rename single feature
>>> b_1 = b["f1"].rename("f1_result")
>>> b_1
indexes: []
features: [('f1_result', int64)]
events:
(2 events):
timestamps: [0. 1.]
'f1_result': [ 0 10]
...
>>> # Rename multiple features with a dictionary
>>> b_rename = b.rename({"f1": "5xf1", "f2": "5xf2"})
>>> b_rename
indexes: []
features: [('5xf1', int64), ('5xf2', int64)]
events:
(2 events):
timestamps: [0. 1.]
'5xf1': [ 0 10]
'5xf2': [25 30]
...
>>> # Rename multiple features with a list
>>> b_rename = b.rename(["5xf1", "5xf2"])
>>> b_rename
indexes: []
features: [('5xf1', int64), ('5xf2', int64)]
events:
(2 events):
timestamps: [0. 1.]
'5xf1': [ 0 10]
'5xf2': [25 30]
...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features |
Optional[Union[str, Dict[str, str], List[str]]]
|
New feature name or mapping from old names to new names. |
None
|
indexes |
Optional[Union[str, Dict[str, str], List[str]]]
|
New index name or mapping from old names to new names. |
None
|
Returns:
Type | Description |
---|---|
EventSetOrNode
|
EventSet with renamed features and index. |