From b13a7f5c88f4f09c2744f5756b2739094df16daa Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Sun, 25 Feb 2024 14:41:16 +0000 Subject: [PATCH] docs(python): Improve docstrings for `ewm_*` and `rolling_*` methods (#14667) --- py-polars/polars/dataframe/frame.py | 5 -- py-polars/polars/expr/expr.py | 93 ++++++++++------------------- py-polars/polars/lazyframe/frame.py | 5 -- py-polars/polars/series/series.py | 6 +- 4 files changed, 36 insertions(+), 73 deletions(-) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index b4aa5aada7a7..8fc30f2ffd1d 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -5537,11 +5537,6 @@ def rolling( not be 24 hours, due to daylight savings). Similarly for "calendar week", "calendar month", "calendar quarter", and "calendar year". - In case of a rolling operation on an integer column, the windows are defined by: - - - **"1i" # length 1** - - **"10i" # length 10** - Parameters ---------- index_column diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index 2539f09830e5..d870bc8ca528 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -3339,11 +3339,6 @@ def rolling( not be 24 hours, due to daylight savings). Similarly for "calendar week", "calendar month", "calendar quarter", and "calendar year". - In case of a rolling operation on an integer column, the windows are defined by: - - - "1i" # length 1 - - "10i" # length 10 - Parameters ---------- index_column @@ -5716,16 +5711,13 @@ def rolling_min( If `by` has not been specified (the default), the window at a given row will include the row itself, and the `window_size - 1` elements before it. - If you pass a `by` column ``, then `closed="left"` - means the windows will be: + If you pass a `by` column ``, then `closed="right"` + (the default) means the windows will be: - - [t_0 - window_size, t_0) - - [t_1 - window_size, t_1) + - (t_0 - window_size, t_0] + - (t_1 - window_size, t_1] - ... - - [t_n - window_size, t_n) - - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. + - (t_n - window_size, t_n] Parameters ---------- @@ -5931,16 +5923,13 @@ def rolling_max( If `by` has not been specified (the default), the window at a given row will include the row itself, and the `window_size - 1` elements before it. - If you pass a `by` column ``, then `closed="left"` - means the windows will be: + If you pass a `by` column ``, then `closed="right"` + (the default) means the windows will be: - - [t_0 - window_size, t_0) - - [t_1 - window_size, t_1) + - (t_0 - window_size, t_0] + - (t_1 - window_size, t_1] - ... - - [t_n - window_size, t_n) - - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. + - (t_n - window_size, t_n] Parameters ---------- @@ -6171,16 +6160,13 @@ def rolling_mean( If `by` has not been specified (the default), the window at a given row will include the row itself, and the `window_size - 1` elements before it. - If you pass a `by` column ``, then `closed="left"` - means the windows will be: + If you pass a `by` column ``, then `closed="right"` + (the default) means the windows will be: - - [t_0 - window_size, t_0) - - [t_1 - window_size, t_1) + - (t_0 - window_size, t_0] + - (t_1 - window_size, t_1] - ... - - [t_n - window_size, t_n) - - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. + - (t_n - window_size, t_n] Parameters ---------- @@ -6421,16 +6407,13 @@ def rolling_sum( If `by` has not been specified (the default), the window at a given row will include the row itself, and the `window_size - 1` elements before it. - If you pass a `by` column ``, then `closed="left"` - means the windows will be: + If you pass a `by` column ``, then `closed="right"` + (the default) means the windows will be: - - [t_0 - window_size, t_0) - - [t_1 - window_size, t_1) + - (t_0 - window_size, t_0] + - (t_1 - window_size, t_1] - ... - - [t_n - window_size, t_n) - - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. + - (t_n - window_size, t_n] Parameters ---------- @@ -6666,8 +6649,6 @@ def rolling_std( - ... - [t_n - window_size, t_n) - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. Parameters ---------- @@ -6908,16 +6889,13 @@ def rolling_var( If `by` has not been specified (the default), the window at a given row will include the row itself, and the `window_size - 1` elements before it. - If you pass a `by` column ``, then `closed="left"` - means the windows will be: + If you pass a `by` column ``, then `closed="right"` + (the default) means the windows will be: - - [t_0 - window_size, t_0) - - [t_1 - window_size, t_1) + - (t_0 - window_size, t_0] + - (t_1 - window_size, t_1] - ... - - [t_n - window_size, t_n) - - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. + - (t_n - window_size, t_n] Parameters ---------- @@ -7165,8 +7143,6 @@ def rolling_median( - ... - [t_n - window_size, t_n) - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. Parameters ---------- @@ -7319,16 +7295,13 @@ def rolling_quantile( If `by` has not been specified (the default), the window at a given row will include the row itself, and the `window_size - 1` elements before it. - If you pass a `by` column ``, then `closed="left"` - means the windows will be: + If you pass a `by` column ``, then `closed="right"` + (the default) means the windows will be: - - [t_0 - window_size, t_0) - - [t_1 - window_size, t_1) + - (t_0 - window_size, t_0] + - (t_1 - window_size, t_1] - ... - - [t_n - window_size, t_n) - - With `closed="right"`, the left endpoint is not included and the right - endpoint is included. + - (t_n - window_size, t_n] Parameters ---------- @@ -8587,7 +8560,7 @@ def ewm_mean( Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings - - When `adjust=True` the EW function is calculated + - When `adjust=True` (the default) the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` - When `adjust=False` the EW function is calculated recursively by @@ -8686,7 +8659,7 @@ def ewm_std( Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings - - When `adjust=True` the EW function is calculated + - When `adjust=True` (the default) the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` - When `adjust=False` the EW function is calculated recursively by @@ -8788,7 +8761,7 @@ def ewm_var( Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings - - When `adjust=True` the EW function is calculated + - When `adjust=True` (the default) the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` - When `adjust=False` the EW function is calculated recursively by diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index c6e2c8f4ed0c..e4e2dc9681fd 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -3277,11 +3277,6 @@ def rolling( not be 24 hours, due to daylight savings). Similarly for "calendar week", "calendar month", "calendar quarter", and "calendar year". - In case of a rolling operation on an integer column, the windows are defined by: - - - "1i" # length 1 - - "10i" # length 10 - Parameters ---------- index_column diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index bf21bef58aa5..0ad26377f80a 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -6808,7 +6808,7 @@ def ewm_mean( Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings - - When `adjust=True` the EW function is calculated + - When `adjust=True` (the default) the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` - When `adjust=False` the EW function is calculated recursively by @@ -6890,7 +6890,7 @@ def ewm_std( Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings - - When `adjust=True` the EW function is calculated + - When `adjust=True` (the default) the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` - When `adjust=False` the EW function is calculated recursively by @@ -6975,7 +6975,7 @@ def ewm_var( Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings - - When `adjust=True` the EW function is calculated + - When `adjust=True` (the default) the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` - When `adjust=False` the EW function is calculated recursively by