You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `window_func` parameter in the `augment_expanding` function specifies the function(s) to be applied to the expanding windows of the value column(s).
35
-
36
+
The `window_func` parameter in the `augment_expanding` function specifies
37
+
the function(s) to be applied to the expanding windows of the value column(s).
38
+
36
39
1. It can be either:
37
40
- A string representing the name of a standard function (e.g., 'mean', 'sum').
38
-
41
+
39
42
2. For custom functions:
40
-
- Provide a list of tuples. Each tuple should contain a custom name for the function and the function itself.
41
-
- Each custom function should accept a Pandas Series as its input and operate on that series.
42
-
Example: ("range", lambda x: x.max() - x.min())
43
-
43
+
- Provide a list of tuples. Each tuple should contain a custom name for
44
+
the function and the function itself.
45
+
- Each custom function should accept a Pandas Series as its input and
46
+
operate on that series. Example: ("range", lambda x: x.max() - x.min())
47
+
44
48
(See more Examples below.)
45
-
46
-
Note: If your function needs to operate on multiple columns (i.e., it requires access to a DataFrame rather than just a Series), consider using the `augment_expanding_apply` function in this library.
49
+
50
+
Note: If your function needs to operate on multiple columns (i.e., it
51
+
requires access to a DataFrame rather than just a Series), consider
52
+
using the `augment_expanding_apply` function in this library.
47
53
min_periods : int, optional, default None
48
-
Minimum observations in the window to have a value. Defaults to the window size. If set, a value will be produced even if fewer observations are present than the window size.
54
+
Minimum observations in the window to have a value. Defaults to the window
55
+
size. If set, a value will be produced even if fewer observations are
56
+
present than the window size.
49
57
engine : str, optional, default 'pandas'
50
-
Specifies the backend computation library for augmenting expanding window functions.
51
-
58
+
Specifies the backend computation library for augmenting expanding window
59
+
functions.
60
+
52
61
The options are:
53
62
- "pandas" (default): Uses the `pandas` library.
54
-
- "polars": Uses the `polars` library, which may offer performance benefits for larger datasets.
55
-
63
+
- "polars": Uses the `polars` library, which may offer performance
64
+
benefits for larger datasets.
65
+
56
66
**kwargs : additional keyword arguments
57
-
Additional arguments passed to the `pandas.Series.expanding` method when using the Pandas engine.
58
-
67
+
Additional arguments passed to the `pandas.Series.expanding` method when
68
+
using the Pandas engine.
69
+
59
70
Returns
60
71
-------
61
72
pd.DataFrame
62
-
The `augment_expanding` function returns a DataFrame with new columns for each applied function, window size, and value column.
63
-
73
+
The `augment_expanding` function returns a DataFrame with new columns for
74
+
each applied function, window size, and value column.
75
+
64
76
Examples
65
77
--------
66
-
78
+
67
79
```{python}
68
80
# Example 1 - Pandas Backend for Expanding Window Functions
69
81
# This example demonstrates the use of string-named functions
70
82
# on an expanding window using the Pandas backend for computations.
The `window_func` parameter in the `augment_expanding_apply` function specifies the function(s) that operate on a expanding window with the consideration of multiple columns.
476
-
489
+
The `window_func` parameter in the `augment_expanding_apply` function
490
+
specifies the function(s) that operate on a expanding window with the
491
+
consideration of multiple columns.
492
+
477
493
The specification can be:
478
494
- A tuple where the first element is a string representing the function's name and the second element is the callable function itself.
479
495
- A list of such tuples for multiple functions.
480
-
481
-
Note: For functions targeting only a single value column without the need for contextual data from other columns, consider using the `augment_expanding` function in this library.
482
-
min_periods : int, optional, default None
483
-
Minimum observations in the window to have a value. Defaults to the window size. If set, a value will be produced even if fewer observations are present than the window size.
484
496
497
+
Note: For functions targeting only a single value column without the need for
498
+
contextual data from other columns, consider using the `augment_expanding`
499
+
function in this library.
500
+
min_periods : int, optional, default None
501
+
Minimum observations in the window to have a value. Defaults to the window
502
+
size. If set, a value will be produced even if fewer observations are
503
+
present than the window size.
504
+
485
505
Returns
486
506
-------
487
507
pd.DataFrame
488
-
The `augment_expanding` function returns a DataFrame with new columns for each applied function, window size, and value column.
489
-
508
+
The `augment_expanding` function returns a DataFrame with new columns
509
+
for each applied function, window size, and value column.
510
+
490
511
Examples
491
512
--------
492
513
```{python}
493
514
import pytimetk as tk
494
515
import pandas as pd
495
516
import numpy as np
496
517
```
497
-
518
+
498
519
```{python}
499
-
# Example showcasing the expanding correlation between two columns (`value1` and `value2`).
520
+
# Example showcasing the expanding correlation between two columns (`value1` and
521
+
# `value2`).
500
522
# The correlation requires both columns as input.
501
-
523
+
502
524
# Sample DataFrame with id, date, value1, and value2 columns.
0 commit comments