temporian.EventSet.propagate #
propagate(
sampling: EventSetOrNode, resample: bool = False
) -> EventSetOrNode
Propagates feature values over another EventSet
's
index.
Given the input and sampling
where the input's indexes are a subset of
sampling
's (e.g., the indexes of the input are ["x"]
, and the indexes of
sampling
are ["x","y"]
), duplicates the features of the input over the
indexes of sampling
.
Index values in self
but not in sampling
are removed. An index value
without timestamps is created for each index values in sampling
but
not in self
.
Example use case
>>> products = tp.event_set(
... timestamps=[1, 2, 3, 1, 2, 3],
... features={
... "product": [1, 1, 1, 2, 2, 2],
... "sales": [100., 200., 500., 1000., 2000., 5000.]
... },
... indexes=["product"],
... )
>>> store = tp.event_set(
... timestamps=[1, 2, 3, 4, 5],
... features={
... "sales": [10000., 20000., 30000., 5000., 1000.]
... },
... )
>>> # First attempt: divide to calculate fraction of total store sales
>>> products / store
Traceback (most recent call last):
...
ValueError: Arguments don't have the same index. ...
>>> # Second attempt: propagate index
>>> store_prop = store.propagate(products)
>>> products / store_prop
Traceback (most recent call last):
...
ValueError: Arguments should have the same sampling. ...
>>> # Third attempt: propagate + resample
>>> store_resample = store.propagate(products, resample=True)
>>> div = products / store_resample
>>> div
indexes: [('product', int64)]
features: [('div_sales_sales', float64)]
events:
product=1 (3 events):
timestamps: [1. 2. 3.]
'div_sales_sales': [0.01 0.01 0.0167]
product=2 (3 events):
timestamps: [1. 2. 3.]
'div_sales_sales': [0.1 0.1 0.1667]
...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sampling |
EventSetOrNode
|
EventSet with the indexes to propagate to. |
required |
resample |
bool
|
If true, apply a |
False
|
Returns:
Type | Description |
---|---|
EventSetOrNode
|
EventSet propagated over |