Skip to content

Commit

Permalink
docs(python): Improve docstrings for ewm_* and rolling_* methods (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 25, 2024
1 parent 912edc3 commit b13a7f5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 73 deletions.
5 changes: 0 additions & 5 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
93 changes: 33 additions & 60 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 `<t_0, t_1, ..., t_n>`, then `closed="left"`
means the windows will be:
If you pass a `by` column `<t_0, t_1, ..., t_n>`, 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
----------
Expand Down Expand Up @@ -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 `<t_0, t_1, ..., t_n>`, then `closed="left"`
means the windows will be:
If you pass a `by` column `<t_0, t_1, ..., t_n>`, 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
----------
Expand Down Expand Up @@ -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 `<t_0, t_1, ..., t_n>`, then `closed="left"`
means the windows will be:
If you pass a `by` column `<t_0, t_1, ..., t_n>`, 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
----------
Expand Down Expand Up @@ -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 `<t_0, t_1, ..., t_n>`, then `closed="left"`
means the windows will be:
If you pass a `by` column `<t_0, t_1, ..., t_n>`, 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
----------
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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 `<t_0, t_1, ..., t_n>`, then `closed="left"`
means the windows will be:
If you pass a `by` column `<t_0, t_1, ..., t_n>`, 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
----------
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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 `<t_0, t_1, ..., t_n>`, then `closed="left"`
means the windows will be:
If you pass a `by` column `<t_0, t_1, ..., t_n>`, 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
----------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b13a7f5

Please sign in to comment.