temporian.glue #
glue(*inputs: EventSetOrNode) -> EventSetOrNode
Concatenates features from EventSets
with the
same sampling.
Feature names cannot be duplicated across EventSets.
See the examples below for workarounds on gluing EventSets with duplicated feature names or different samplings.
Example:
```python
>>> a = tp.event_set(
... timestamps=[0, 1, 5],
... features={"M": [0, 10, 50], "N": [50, 100, 500]},
... )
>>> b = a["M"] + a["N"]
>>> c = a["M"] - a["N"]
# Glue all features from a,b,c
>>> d = tp.glue(a, b, c)
>>> d
indexes: []
features: [('M', int64), ('N', int64), ('add_M_N', int64), ('sub_M_N', int64)]
events:
(3 events):
timestamps: [0. 1. 5.]
'M': [ 0 10 50]
'N': [ 50 100 500]
'add_M_N': [ 50 110 550]
'sub_M_N': [ -50 -90 -450]
...
```
To glue EventSets with duplicated feature names, add a prefix or rename them before.
Example with duplicated names:
```python
>>> a = tp.event_set(
... timestamps=[0, 1, 5],
... features={"M": [0, 10, 50], "N": [50, 100, 500]},
... )
# Same feature names as a
>>> b = 3 * a
# Add a prefix before glue
>>> output = tp.glue(a, b.prefix("3x"))
>>> output.schema.features
[('M', int64), ('N', int64), ('3xM', int64), ('3xN', int64)]
# Or rename before glue
>>> output = tp.glue(a["M"], b["M"].rename("M_new"))
>>> output.schema.features
[('M', int64), ('M_new', int64)]
```
To concatenate EventSets with different samplings, use
EventSet.resample()
first.
Example with different samplings:
```python
>>> a = tp.event_set(timestamps=[0, 2], features={"A": [0, 20]})
>>> b = tp.event_set(timestamps=[0, 2], features={"B": [1, 21]})
>>> c = tp.event_set(timestamps=[1, 4], features={"C": [10, 40]})
>>> output = tp.glue(a, b.resample(a), c.resample(a))
>>> output
indexes: []
features: [('A', int64), ('B', int64), ('C', int64)]
events:
(2 events):
timestamps: [0. 2.]
'A': [ 0 20]
'B': [ 1 21]
'C': [ 0 10]
...
```
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*inputs |
EventSetOrNode
|
EventSets to concatenate the features of. |
()
|
Returns:
Type | Description |
---|---|
EventSetOrNode
|
EventSet with concatenated features. |