From 0f37edfa9acb356ec0e7797ada9a153f8709e334 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Mon, 11 Sep 2023 01:02:33 +0200 Subject: [PATCH] docs(python): warn that "by" argument must be sorted for results to be correct in rolling_* functions (#11013) --- py-polars/polars/expr/expr.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index 81e69a22b801..8dea34ae6984 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -5345,6 +5345,10 @@ def rolling_min( If the `window_size` is temporal for instance `"5h"` or `"3s"`, you must set the column that will be used to determine the windows. This column must be of dtype Datetime. + + .. warning:: + If passed, the column must be sorted in ascending order. Otherwise, + results will not be correct. closed : {'left', 'right', 'both', 'none'} Define which sides of the temporal interval are closed (inclusive); only applicable if `by` has been set. @@ -5784,6 +5788,10 @@ def rolling_mean( If the `window_size` is temporal for instance `"5h"` or `"3s"`, you must set the column that will be used to determine the windows. This column must be of dtype Datetime. + + .. warning:: + If passed, the column must be sorted in ascending order. Otherwise, + results will not be correct. closed : {'left', 'right', 'both', 'none'} Define which sides of the temporal interval are closed (inclusive); only applicable if `by` has been set. @@ -6247,6 +6255,10 @@ def rolling_std( If the `window_size` is temporal for instance `"5h"` or `"3s"`, you must set the column that will be used to determine the windows. This column must be of dtype Datetime. + + .. warning:: + If passed, the column must be sorted in ascending order. Otherwise, + results will not be correct. closed : {'left', 'right', 'both', 'none'} Define which sides of the temporal interval are closed (inclusive); only applicable if `by` has been set. @@ -6479,6 +6491,10 @@ def rolling_var( If the `window_size` is temporal for instance `"5h"` or `"3s"`, you must set the column that will be used to determine the windows. This column must be of dtype Datetime. + + .. warning:: + If passed, the column must be sorted in ascending order. Otherwise, + results will not be correct. closed : {'left', 'right', 'both', 'none'} Define which sides of the temporal interval are closed (inclusive); only applicable if `by` has been set. @@ -6716,6 +6732,10 @@ def rolling_median( If the `window_size` is temporal for instance `"5h"` or `"3s"`, you must set the column that will be used to determine the windows. This column must be of dtype Datetime. + + .. warning:: + If passed, the column must be sorted in ascending order. Otherwise, + results will not be correct. closed : {'left', 'right', 'both', 'none'} Define which sides of the temporal interval are closed (inclusive); only applicable if `by` has been set. @@ -6877,6 +6897,10 @@ def rolling_quantile( If the `window_size` is temporal for instance `"5h"` or `"3s"`, you must set the column that will be used to determine the windows. This column must be of dtype Datetime. + + .. warning:: + If passed, the column must be sorted in ascending order. Otherwise, + results will not be correct. closed : {'left', 'right', 'both', 'none'} Define which sides of the temporal interval are closed (inclusive); only applicable if `by` has been set.