temporian.EventSet.cumprod #
cumprod(
sampling: Optional[EventSetOrNode] = None,
) -> EventSetOrNode
Computes the cumulative product of values over each feature in an
EventSet
.
This operation only supports floating-point features.
Missing (NaN) values are not accounted for. The output will be NaN until the input contains at least one numeric value.
Warning: The cumprod
function leverages an infinite window length for
its calculations, which may lead to considerable computational overhead
with increasing dataset sizes.
Example
>>> a = tp.event_set(
... timestamps=[0, 1, 2, 3],
... features={"value": [1.0, 2.0, 10.0, 12.0]},
... )
>>> b = a.cumprod()
>>> b
indexes: ...
(4 events):
timestamps: [0. 1. 2. 3.]
'value': [ 1. 2. 20. 240.]
...
Examples with sampling
>>> a = tp.event_set(
... timestamps=[0, 1, 2, 5, 6, 7],
... features={"value": [1, 2, 10, 12, np.nan, 2]},
... )
>>> # Cumulative product at 5 and 10
>>> b = tp.event_set(timestamps=[5, 10])
>>> c = a.cumprod(sampling=b)
>>> c
indexes: ...
(2 events):
timestamps: [ 5. 10.]
'value': [240. 480.]
...
>>> # Product all values in the EventSet
>>> c = a.cumprod(sampling=a.end())
>>> c
indexes: ...
(1 events):
timestamps: [7.]
'value': [480.]
...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sampling |
Optional[EventSetOrNode]
|
Timestamps to sample the sliding window's value at. If not provided, timestamps in the input are used. |
None
|
Returns:
Type | Description |
---|---|
EventSetOrNode
|
Cumulative product of each feature. |