From 4ef4c755a94be58aefc874a69311b4a73a5f62f6 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Mon, 3 Jun 2024 04:15:37 +0000 Subject: [PATCH] feat: finish rolling_*_by in R side --- R/expr__expr.R | 138 ++++-- man/Expr_rolling_quantile_by.Rd | 74 +++ man/Expr_rolling_std_by.Rd | 73 +++ man/Expr_rolling_var_by.Rd | 73 +++ tests/testthat/_snaps/after-wrappers.md | 581 ++++++++++++------------ tests/testthat/test-expr_expr.R | 60 +-- 6 files changed, 647 insertions(+), 352 deletions(-) create mode 100644 man/Expr_rolling_quantile_by.Rd create mode 100644 man/Expr_rolling_std_by.Rd create mode 100644 man/Expr_rolling_var_by.Rd diff --git a/R/expr__expr.R b/R/expr__expr.R index 3b2894ba0..9f208ed42 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -2330,7 +2330,6 @@ Expr_rolling_min = function( #' #' @inherit Expr_rolling_min params return details #' @inheritParams Expr_rolling -#' #' @param by This column must of dtype [`Date`][pl_date] or #' [`Datetime`][DataType_Datetime]. #' @@ -2351,8 +2350,7 @@ Expr_rolling_min_by = function( min_periods = 1, closed = "right") { .pr$Expr$rolling_min_by( - self, - by = by, window_size = window_size, min_periods = min_periods, closed = closed + self, by, window_size, min_periods, closed ) |> unwrap("in $rolling_min_by():") } @@ -2382,12 +2380,7 @@ Expr_rolling_max = function( #' Apply a rolling max based on another column. #' -#' @inherit Expr_rolling_min params return details -#' @inheritParams Expr_rolling -#' -#' @param by This column must of dtype [`Date`][pl_date] or -#' [`Datetime`][DataType_Datetime]. -#' +#' @inherit Expr_rolling_min_by params return details #' @examples #' df_temporal = pl$DataFrame( #' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") @@ -2405,8 +2398,7 @@ Expr_rolling_max_by = function( min_periods = 1, closed = "right") { .pr$Expr$rolling_max_by( - self, - by = by, window_size = window_size, min_periods = min_periods, closed = closed + self, by, window_size, min_periods, closed ) |> unwrap("in $rolling_max_by():") } @@ -2436,12 +2428,7 @@ Expr_rolling_mean = function( #' Apply a rolling mean based on another column. #' -#' @inherit Expr_rolling_min params return details -#' @inheritParams Expr_rolling -#' -#' @param by This column must of dtype [`Date`][pl_date] or -#' [`Datetime`][DataType_Datetime]. -#' +#' @inherit Expr_rolling_min_by params return details #' @examples #' df_temporal = pl$DataFrame( #' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") @@ -2460,7 +2447,7 @@ Expr_rolling_mean_by = function( closed = "right") { .pr$Expr$rolling_mean_by( self, - by = by, window_size = window_size, min_periods = min_periods, closed = closed + by, window_size, min_periods, closed ) |> unwrap("in $rolling_mean_by():") } @@ -2490,12 +2477,7 @@ Expr_rolling_sum = function( #' Apply a rolling sum based on another column. #' -#' @inherit Expr_rolling_min params return details -#' @inheritParams Expr_rolling -#' -#' @param by This column must of dtype [`Date`][pl_date] or -#' [`Datetime`][DataType_Datetime]. -#' +#' @inherit Expr_rolling_min_by params return details #' @examples #' df_temporal = pl$DataFrame( #' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") @@ -2513,8 +2495,7 @@ Expr_rolling_sum_by = function( min_periods = 1, closed = "right") { .pr$Expr$rolling_sum_by( - self, - by = by, window_size = window_size, min_periods = min_periods, closed = closed + self, by, window_size, min_periods, closed ) |> unwrap("in $rolling_sum_by():") } @@ -2544,6 +2525,39 @@ Expr_rolling_std = function( unwrap("in $rolling_std(): ") } +#' Compute a rolling standard deviation based on another column +#' +#' @inherit Expr_rolling_min_by params return details +#' @inheritParams Expr_rolling_std +#' @examples +#' df_temporal = pl$DataFrame( +#' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") +#' )$with_row_index("index") +#' +#' df_temporal +#' +#' # Compute the rolling std with the temporal windows closed on the right (default) +#' df_temporal$with_columns( +#' rolling_row_std = pl$col("index")$rolling_std_by("date", window_size = "2h") +#' ) +#' +#' # Compute the rolling std with the closure of windows on both sides +#' df_temporal$with_columns( +#' rolling_row_std = pl$col("index")$rolling_std_by("date", window_size = "2h", closed = "both") +#' ) +Expr_rolling_std_by = function( + by, + window_size, + ..., + min_periods = 1, + closed = "right", + ddof = 1) { + .pr$Expr$rolling_std_by( + self, by, window_size, min_periods, closed, ddof + ) |> + unwrap("in $rolling_std_by():") +} + #' Rolling variance #' #' Compute the rolling (= moving) variance over the values in this array. A @@ -2568,6 +2582,40 @@ Expr_rolling_var = function( unwrap("in $rolling_var():") } +#' Compute a rolling variance based on another column +#' +#' @inherit Expr_rolling_min_by params return details +#' @inheritParams Expr_rolling_var +#' @examples +#' df_temporal = pl$DataFrame( +#' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") +#' )$with_row_index("index") +#' +#' df_temporal +#' +#' # Compute the rolling var with the temporal windows closed on the right (default) +#' df_temporal$with_columns( +#' rolling_row_var = pl$col("index")$rolling_var_by("date", window_size = "2h") +#' ) +#' +#' # Compute the rolling var with the closure of windows on both sides +#' df_temporal$with_columns( +#' rolling_row_var = pl$col("index")$rolling_var_by("date", window_size = "2h", closed = "both") +#' ) +Expr_rolling_var_by = function( + by, + window_size, + ..., + min_periods = 1, + closed = "right", + ddof = 1) { + .pr$Expr$rolling_var_by( + self, by, window_size, min_periods, closed, + ddof = ddof + ) |> + unwrap("in $rolling_var_by():") +} + #' Rolling median #' #' Compute the rolling (= moving) median over the values in this array. A window @@ -2593,12 +2641,7 @@ Expr_rolling_median = function( #' Apply a rolling median based on another column. #' -#' @inherit Expr_rolling_min params return details -#' @inheritParams Expr_rolling -#' -#' @param by This column must of dtype [`Date`][pl_date] or -#' [`Datetime`][DataType_Datetime]. -#' +#' @inherit Expr_rolling_min_by params return details #' @examples #' df_temporal = pl$DataFrame( #' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") @@ -2616,8 +2659,7 @@ Expr_rolling_median_by = function( min_periods = 1, closed = "right") { .pr$Expr$rolling_median_by( - self, - by = by, window_size = window_size, min_periods = min_periods, closed = closed + self, by, window_size, min_periods, closed ) |> unwrap("in $rolling_median_by():") } @@ -2651,6 +2693,34 @@ Expr_rolling_quantile = function( unwrap("in $rolling_quantile():") } +#' Compute a rolling quantile based on another column +#' +#' @inherit Expr_rolling_min_by params return details +#' @inheritParams Expr_quantile +#' @examples +#' df_temporal = pl$DataFrame( +#' date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") +#' )$with_row_index("index") +#' +#' df_temporal +#' +#' df_temporal$with_columns( +#' rolling_row_quantile = pl$col("index")$rolling_quantile_by("date", window_size = "2h", quantile = 0.3) +#' ) +Expr_rolling_quantile_by = function( + by, + window_size, + ..., + quantile, + interpolation = "nearest", + min_periods = 1, + closed = "right") { + .pr$Expr$rolling_quantile_by( + self, + by, quantile, interpolation, window_size, min_periods, closed + ) |> + unwrap("in $rolling_quantile_by():") +} #' Rolling skew #' diff --git a/man/Expr_rolling_quantile_by.Rd b/man/Expr_rolling_quantile_by.Rd new file mode 100644 index 000000000..96f74ee73 --- /dev/null +++ b/man/Expr_rolling_quantile_by.Rd @@ -0,0 +1,74 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/expr__expr.R +\name{Expr_rolling_quantile_by} +\alias{Expr_rolling_quantile_by} +\title{Compute a rolling quantile based on another column} +\usage{ +Expr_rolling_quantile_by( + by, + window_size, + ..., + quantile, + interpolation = "nearest", + min_periods = 1, + closed = "right" +) +} +\arguments{ +\item{by}{This column must of dtype \code{\link[=pl_date]{Date}} or +\code{\link[=DataType_Datetime]{Datetime}}.} + +\item{window_size}{The length of the window. Can be a fixed integer size, or a dynamic temporal +size indicated by the following string language: +\itemize{ +\item 1ns (1 nanosecond) +\item 1us (1 microsecond) +\item 1ms (1 millisecond) +\item 1s (1 second) +\item 1m (1 minute) +\item 1h (1 hour) +\item 1d (1 day) +\item 1w (1 week) +\item 1mo (1 calendar month) +\item 1y (1 calendar year) +\item 1i (1 index count) +If the dynamic string language is used, the \code{by} and \code{closed} arguments must +also be set. +}} + +\item{...}{Ignored.} + +\item{quantile}{Either a numeric value or an Expr whose value must be +between 0 and 1.} + +\item{interpolation}{One of \code{"nearest"}, \code{"higher"}, \code{"lower"}, +\code{"midpoint"}, or \code{"linear"}.} + +\item{min_periods}{The number of values in the window that should be non-null +before computing a result. If \code{NULL}, it will be set equal to window size.} + +\item{closed}{Define which sides of the temporal interval are closed +(inclusive). This can be either \code{"left"}, \code{"right"}, \code{"both"} or \code{"none"}.} +} +\value{ +Expr +} +\description{ +Compute a rolling quantile based on another column +} +\details{ +If you want to compute multiple aggregation statistics over the same dynamic +window, consider using \verb{$rolling()} this method can cache the window size +computation. +} +\examples{ +df_temporal = pl$DataFrame( + date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") +)$with_row_index("index") + +df_temporal + +df_temporal$with_columns( + rolling_row_quantile = pl$col("index")$rolling_quantile_by("date", window_size = "2h", quantile = 0.3) +) +} diff --git a/man/Expr_rolling_std_by.Rd b/man/Expr_rolling_std_by.Rd new file mode 100644 index 000000000..dbc6dd784 --- /dev/null +++ b/man/Expr_rolling_std_by.Rd @@ -0,0 +1,73 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/expr__expr.R +\name{Expr_rolling_std_by} +\alias{Expr_rolling_std_by} +\title{Compute a rolling standard deviation based on another column} +\usage{ +Expr_rolling_std_by( + by, + window_size, + ..., + min_periods = 1, + closed = "right", + ddof = 1 +) +} +\arguments{ +\item{by}{This column must of dtype \code{\link[=pl_date]{Date}} or +\code{\link[=DataType_Datetime]{Datetime}}.} + +\item{window_size}{The length of the window. Can be a fixed integer size, or a dynamic temporal +size indicated by the following string language: +\itemize{ +\item 1ns (1 nanosecond) +\item 1us (1 microsecond) +\item 1ms (1 millisecond) +\item 1s (1 second) +\item 1m (1 minute) +\item 1h (1 hour) +\item 1d (1 day) +\item 1w (1 week) +\item 1mo (1 calendar month) +\item 1y (1 calendar year) +\item 1i (1 index count) +If the dynamic string language is used, the \code{by} and \code{closed} arguments must +also be set. +}} + +\item{...}{Ignored.} + +\item{min_periods}{The number of values in the window that should be non-null +before computing a result. If \code{NULL}, it will be set equal to window size.} + +\item{closed}{Define which sides of the temporal interval are closed +(inclusive). This can be either \code{"left"}, \code{"right"}, \code{"both"} or \code{"none"}.} +} +\value{ +Expr +} +\description{ +Compute a rolling standard deviation based on another column +} +\details{ +If you want to compute multiple aggregation statistics over the same dynamic +window, consider using \verb{$rolling()} this method can cache the window size +computation. +} +\examples{ +df_temporal = pl$DataFrame( + date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") +)$with_row_index("index") + +df_temporal + +# Compute the rolling std with the temporal windows closed on the right (default) +df_temporal$with_columns( + rolling_row_std = pl$col("index")$rolling_std_by("date", window_size = "2h") +) + +# Compute the rolling std with the closure of windows on both sides +df_temporal$with_columns( + rolling_row_std = pl$col("index")$rolling_std_by("date", window_size = "2h", closed = "both") +) +} diff --git a/man/Expr_rolling_var_by.Rd b/man/Expr_rolling_var_by.Rd new file mode 100644 index 000000000..eb46442c1 --- /dev/null +++ b/man/Expr_rolling_var_by.Rd @@ -0,0 +1,73 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/expr__expr.R +\name{Expr_rolling_var_by} +\alias{Expr_rolling_var_by} +\title{Compute a rolling variance based on another column} +\usage{ +Expr_rolling_var_by( + by, + window_size, + ..., + min_periods = 1, + closed = "right", + ddof = 1 +) +} +\arguments{ +\item{by}{This column must of dtype \code{\link[=pl_date]{Date}} or +\code{\link[=DataType_Datetime]{Datetime}}.} + +\item{window_size}{The length of the window. Can be a fixed integer size, or a dynamic temporal +size indicated by the following string language: +\itemize{ +\item 1ns (1 nanosecond) +\item 1us (1 microsecond) +\item 1ms (1 millisecond) +\item 1s (1 second) +\item 1m (1 minute) +\item 1h (1 hour) +\item 1d (1 day) +\item 1w (1 week) +\item 1mo (1 calendar month) +\item 1y (1 calendar year) +\item 1i (1 index count) +If the dynamic string language is used, the \code{by} and \code{closed} arguments must +also be set. +}} + +\item{...}{Ignored.} + +\item{min_periods}{The number of values in the window that should be non-null +before computing a result. If \code{NULL}, it will be set equal to window size.} + +\item{closed}{Define which sides of the temporal interval are closed +(inclusive). This can be either \code{"left"}, \code{"right"}, \code{"both"} or \code{"none"}.} +} +\value{ +Expr +} +\description{ +Compute a rolling variance based on another column +} +\details{ +If you want to compute multiple aggregation statistics over the same dynamic +window, consider using \verb{$rolling()} this method can cache the window size +computation. +} +\examples{ +df_temporal = pl$DataFrame( + date = pl$datetime_range(as.Date("2001-1-1"), as.Date("2001-1-2"), "1h") +)$with_row_index("index") + +df_temporal + +# Compute the rolling var with the temporal windows closed on the right (default) +df_temporal$with_columns( + rolling_row_var = pl$col("index")$rolling_var_by("date", window_size = "2h") +) + +# Compute the rolling var with the closure of windows on both sides +df_temporal$with_columns( + rolling_row_var = pl$col("index")$rolling_var_by("date", window_size = "2h", closed = "both") +) +} diff --git a/tests/testthat/_snaps/after-wrappers.md b/tests/testthat/_snaps/after-wrappers.md index be12fd230..6dac0553b 100644 --- a/tests/testthat/_snaps/after-wrappers.md +++ b/tests/testthat/_snaps/after-wrappers.md @@ -215,67 +215,68 @@ Code ls(.pr$env[[class_name]]) Output - [1] "abs" "add" "agg_groups" - [4] "alias" "all" "and" - [7] "any" "append" "approx_n_unique" - [10] "arccos" "arccosh" "arcsin" - [13] "arcsinh" "arctan" "arctanh" - [16] "arg_max" "arg_min" "arg_sort" - [19] "arg_unique" "arr" "backward_fill" - [22] "bin" "bottom_k" "cast" - [25] "cat" "ceil" "clip" - [28] "clip_max" "clip_min" "cos" - [31] "cosh" "count" "cum_count" - [34] "cum_max" "cum_min" "cum_prod" - [37] "cum_sum" "cumulative_eval" "cut" - [40] "diff" "div" "dot" - [43] "drop_nans" "drop_nulls" "dt" - [46] "entropy" "eq" "eq_missing" - [49] "ewm_mean" "ewm_std" "ewm_var" - [52] "exclude" "exp" "explode" - [55] "extend_constant" "fill_nan" "fill_null" - [58] "filter" "first" "flatten" - [61] "floor" "floor_div" "forward_fill" - [64] "gather" "gather_every" "gt" - [67] "gt_eq" "hash" "head" - [70] "implode" "inspect" "interpolate" - [73] "is_between" "is_duplicated" "is_finite" - [76] "is_first_distinct" "is_in" "is_infinite" - [79] "is_last_distinct" "is_nan" "is_not_nan" - [82] "is_not_null" "is_null" "is_unique" - [85] "kurtosis" "last" "len" - [88] "limit" "list" "log" - [91] "log10" "lower_bound" "lt" - [94] "lt_eq" "map_batches" "map_elements" - [97] "max" "mean" "median" - [100] "meta" "min" "mod" - [103] "mode" "mul" "n_unique" - [106] "name" "nan_max" "nan_min" - [109] "neq" "neq_missing" "not" - [112] "null_count" "or" "over" - [115] "pct_change" "peak_max" "peak_min" - [118] "pow" "print" "product" - [121] "qcut" "quantile" "rank" - [124] "rechunk" "reinterpret" "rep" - [127] "repeat_by" "replace" "reshape" - [130] "reverse" "rle" "rle_id" - [133] "rolling" "rolling_max" "rolling_max_by" - [136] "rolling_mean" "rolling_mean_by" "rolling_median" - [139] "rolling_median_by" "rolling_min" "rolling_min_by" - [142] "rolling_quantile" "rolling_skew" "rolling_std" - [145] "rolling_sum" "rolling_sum_by" "rolling_var" - [148] "round" "sample" "search_sorted" - [151] "set_sorted" "shift" "shift_and_fill" - [154] "shrink_dtype" "shuffle" "sign" - [157] "sin" "sinh" "skew" - [160] "slice" "sort" "sort_by" - [163] "sqrt" "std" "str" - [166] "struct" "sub" "sum" - [169] "tail" "tan" "tanh" - [172] "to_physical" "to_r" "to_series" - [175] "top_k" "unique" "unique_counts" - [178] "upper_bound" "value_counts" "var" - [181] "xor" + [1] "abs" "add" "agg_groups" + [4] "alias" "all" "and" + [7] "any" "append" "approx_n_unique" + [10] "arccos" "arccosh" "arcsin" + [13] "arcsinh" "arctan" "arctanh" + [16] "arg_max" "arg_min" "arg_sort" + [19] "arg_unique" "arr" "backward_fill" + [22] "bin" "bottom_k" "cast" + [25] "cat" "ceil" "clip" + [28] "clip_max" "clip_min" "cos" + [31] "cosh" "count" "cum_count" + [34] "cum_max" "cum_min" "cum_prod" + [37] "cum_sum" "cumulative_eval" "cut" + [40] "diff" "div" "dot" + [43] "drop_nans" "drop_nulls" "dt" + [46] "entropy" "eq" "eq_missing" + [49] "ewm_mean" "ewm_std" "ewm_var" + [52] "exclude" "exp" "explode" + [55] "extend_constant" "fill_nan" "fill_null" + [58] "filter" "first" "flatten" + [61] "floor" "floor_div" "forward_fill" + [64] "gather" "gather_every" "gt" + [67] "gt_eq" "hash" "head" + [70] "implode" "inspect" "interpolate" + [73] "is_between" "is_duplicated" "is_finite" + [76] "is_first_distinct" "is_in" "is_infinite" + [79] "is_last_distinct" "is_nan" "is_not_nan" + [82] "is_not_null" "is_null" "is_unique" + [85] "kurtosis" "last" "len" + [88] "limit" "list" "log" + [91] "log10" "lower_bound" "lt" + [94] "lt_eq" "map_batches" "map_elements" + [97] "max" "mean" "median" + [100] "meta" "min" "mod" + [103] "mode" "mul" "n_unique" + [106] "name" "nan_max" "nan_min" + [109] "neq" "neq_missing" "not" + [112] "null_count" "or" "over" + [115] "pct_change" "peak_max" "peak_min" + [118] "pow" "print" "product" + [121] "qcut" "quantile" "rank" + [124] "rechunk" "reinterpret" "rep" + [127] "repeat_by" "replace" "reshape" + [130] "reverse" "rle" "rle_id" + [133] "rolling" "rolling_max" "rolling_max_by" + [136] "rolling_mean" "rolling_mean_by" "rolling_median" + [139] "rolling_median_by" "rolling_min" "rolling_min_by" + [142] "rolling_quantile" "rolling_quantile_by" "rolling_skew" + [145] "rolling_std" "rolling_std_by" "rolling_sum" + [148] "rolling_sum_by" "rolling_var" "rolling_var_by" + [151] "round" "sample" "search_sorted" + [154] "set_sorted" "shift" "shift_and_fill" + [157] "shrink_dtype" "shuffle" "sign" + [160] "sin" "sinh" "skew" + [163] "slice" "sort" "sort_by" + [166] "sqrt" "std" "str" + [169] "struct" "sub" "sum" + [172] "tail" "tan" "tanh" + [175] "to_physical" "to_r" "to_series" + [178] "top_k" "unique" "unique_counts" + [181] "upper_bound" "value_counts" "var" + [184] "xor" --- @@ -407,47 +408,48 @@ [245] "rolling_mean" "rolling_mean_by" [247] "rolling_median" "rolling_median_by" [249] "rolling_min" "rolling_min_by" - [251] "rolling_quantile" "rolling_skew" - [253] "rolling_std" "rolling_std_by" - [255] "rolling_sum" "rolling_sum_by" - [257] "rolling_var" "round" - [259] "sample_frac" "sample_n" - [261] "search_sorted" "shift" - [263] "shift_and_fill" "shrink_dtype" - [265] "shuffle" "sign" - [267] "sin" "sinh" - [269] "skew" "slice" - [271] "sort_by" "sort_with" - [273] "std" "str_base64_decode" - [275] "str_base64_encode" "str_concat" - [277] "str_contains" "str_contains_any" - [279] "str_count_matches" "str_ends_with" - [281] "str_extract" "str_extract_all" - [283] "str_extract_groups" "str_find" - [285] "str_head" "str_hex_decode" - [287] "str_hex_encode" "str_json_decode" - [289] "str_json_path_match" "str_len_bytes" - [291] "str_len_chars" "str_pad_end" - [293] "str_pad_start" "str_replace" - [295] "str_replace_all" "str_replace_many" - [297] "str_reverse" "str_slice" - [299] "str_split" "str_split_exact" - [301] "str_splitn" "str_starts_with" - [303] "str_strip_chars" "str_strip_chars_end" - [305] "str_strip_chars_start" "str_tail" - [307] "str_to_date" "str_to_datetime" - [309] "str_to_integer" "str_to_lowercase" - [311] "str_to_time" "str_to_titlecase" - [313] "str_to_uppercase" "str_zfill" - [315] "struct_field_by_name" "struct_rename_fields" - [317] "struct_with_fields" "sub" - [319] "sum" "tail" - [321] "tan" "tanh" - [323] "to_physical" "top_k" - [325] "unique" "unique_counts" - [327] "unique_stable" "upper_bound" - [329] "value_counts" "var" - [331] "xor" + [251] "rolling_quantile" "rolling_quantile_by" + [253] "rolling_skew" "rolling_std" + [255] "rolling_std_by" "rolling_sum" + [257] "rolling_sum_by" "rolling_var" + [259] "rolling_var_by" "round" + [261] "sample_frac" "sample_n" + [263] "search_sorted" "shift" + [265] "shift_and_fill" "shrink_dtype" + [267] "shuffle" "sign" + [269] "sin" "sinh" + [271] "skew" "slice" + [273] "sort_by" "sort_with" + [275] "std" "str_base64_decode" + [277] "str_base64_encode" "str_concat" + [279] "str_contains" "str_contains_any" + [281] "str_count_matches" "str_ends_with" + [283] "str_extract" "str_extract_all" + [285] "str_extract_groups" "str_find" + [287] "str_head" "str_hex_decode" + [289] "str_hex_encode" "str_json_decode" + [291] "str_json_path_match" "str_len_bytes" + [293] "str_len_chars" "str_pad_end" + [295] "str_pad_start" "str_replace" + [297] "str_replace_all" "str_replace_many" + [299] "str_reverse" "str_slice" + [301] "str_split" "str_split_exact" + [303] "str_splitn" "str_starts_with" + [305] "str_strip_chars" "str_strip_chars_end" + [307] "str_strip_chars_start" "str_tail" + [309] "str_to_date" "str_to_datetime" + [311] "str_to_integer" "str_to_lowercase" + [313] "str_to_time" "str_to_titlecase" + [315] "str_to_uppercase" "str_zfill" + [317] "struct_field_by_name" "struct_rename_fields" + [319] "struct_with_fields" "sub" + [321] "sum" "tail" + [323] "tan" "tanh" + [325] "to_physical" "top_k" + [327] "unique" "unique_counts" + [329] "unique_stable" "upper_bound" + [331] "value_counts" "var" + [333] "xor" # public and private methods of each class When @@ -468,67 +470,68 @@ Code ls(.pr$env[[class_name]]) Output - [1] "abs" "add" "agg_groups" - [4] "alias" "all" "and" - [7] "any" "append" "approx_n_unique" - [10] "arccos" "arccosh" "arcsin" - [13] "arcsinh" "arctan" "arctanh" - [16] "arg_max" "arg_min" "arg_sort" - [19] "arg_unique" "arr" "backward_fill" - [22] "bin" "bottom_k" "cast" - [25] "cat" "ceil" "clip" - [28] "clip_max" "clip_min" "cos" - [31] "cosh" "count" "cum_count" - [34] "cum_max" "cum_min" "cum_prod" - [37] "cum_sum" "cumulative_eval" "cut" - [40] "diff" "div" "dot" - [43] "drop_nans" "drop_nulls" "dt" - [46] "entropy" "eq" "eq_missing" - [49] "ewm_mean" "ewm_std" "ewm_var" - [52] "exclude" "exp" "explode" - [55] "extend_constant" "fill_nan" "fill_null" - [58] "filter" "first" "flatten" - [61] "floor" "floor_div" "forward_fill" - [64] "gather" "gather_every" "gt" - [67] "gt_eq" "hash" "head" - [70] "implode" "inspect" "interpolate" - [73] "is_between" "is_duplicated" "is_finite" - [76] "is_first_distinct" "is_in" "is_infinite" - [79] "is_last_distinct" "is_nan" "is_not_nan" - [82] "is_not_null" "is_null" "is_unique" - [85] "kurtosis" "last" "len" - [88] "limit" "list" "log" - [91] "log10" "lower_bound" "lt" - [94] "lt_eq" "map_batches" "map_elements" - [97] "max" "mean" "median" - [100] "meta" "min" "mod" - [103] "mode" "mul" "n_unique" - [106] "name" "nan_max" "nan_min" - [109] "neq" "neq_missing" "not" - [112] "null_count" "or" "otherwise" - [115] "over" "pct_change" "peak_max" - [118] "peak_min" "pow" "print" - [121] "product" "qcut" "quantile" - [124] "rank" "rechunk" "reinterpret" - [127] "rep" "repeat_by" "replace" - [130] "reshape" "reverse" "rle" - [133] "rle_id" "rolling" "rolling_max" - [136] "rolling_max_by" "rolling_mean" "rolling_mean_by" - [139] "rolling_median" "rolling_median_by" "rolling_min" - [142] "rolling_min_by" "rolling_quantile" "rolling_skew" - [145] "rolling_std" "rolling_sum" "rolling_sum_by" - [148] "rolling_var" "round" "sample" - [151] "search_sorted" "set_sorted" "shift" - [154] "shift_and_fill" "shrink_dtype" "shuffle" - [157] "sign" "sin" "sinh" - [160] "skew" "slice" "sort" - [163] "sort_by" "sqrt" "std" - [166] "str" "struct" "sub" - [169] "sum" "tail" "tan" - [172] "tanh" "to_physical" "to_r" - [175] "to_series" "top_k" "unique" - [178] "unique_counts" "upper_bound" "value_counts" - [181] "var" "when" "xor" + [1] "abs" "add" "agg_groups" + [4] "alias" "all" "and" + [7] "any" "append" "approx_n_unique" + [10] "arccos" "arccosh" "arcsin" + [13] "arcsinh" "arctan" "arctanh" + [16] "arg_max" "arg_min" "arg_sort" + [19] "arg_unique" "arr" "backward_fill" + [22] "bin" "bottom_k" "cast" + [25] "cat" "ceil" "clip" + [28] "clip_max" "clip_min" "cos" + [31] "cosh" "count" "cum_count" + [34] "cum_max" "cum_min" "cum_prod" + [37] "cum_sum" "cumulative_eval" "cut" + [40] "diff" "div" "dot" + [43] "drop_nans" "drop_nulls" "dt" + [46] "entropy" "eq" "eq_missing" + [49] "ewm_mean" "ewm_std" "ewm_var" + [52] "exclude" "exp" "explode" + [55] "extend_constant" "fill_nan" "fill_null" + [58] "filter" "first" "flatten" + [61] "floor" "floor_div" "forward_fill" + [64] "gather" "gather_every" "gt" + [67] "gt_eq" "hash" "head" + [70] "implode" "inspect" "interpolate" + [73] "is_between" "is_duplicated" "is_finite" + [76] "is_first_distinct" "is_in" "is_infinite" + [79] "is_last_distinct" "is_nan" "is_not_nan" + [82] "is_not_null" "is_null" "is_unique" + [85] "kurtosis" "last" "len" + [88] "limit" "list" "log" + [91] "log10" "lower_bound" "lt" + [94] "lt_eq" "map_batches" "map_elements" + [97] "max" "mean" "median" + [100] "meta" "min" "mod" + [103] "mode" "mul" "n_unique" + [106] "name" "nan_max" "nan_min" + [109] "neq" "neq_missing" "not" + [112] "null_count" "or" "otherwise" + [115] "over" "pct_change" "peak_max" + [118] "peak_min" "pow" "print" + [121] "product" "qcut" "quantile" + [124] "rank" "rechunk" "reinterpret" + [127] "rep" "repeat_by" "replace" + [130] "reshape" "reverse" "rle" + [133] "rle_id" "rolling" "rolling_max" + [136] "rolling_max_by" "rolling_mean" "rolling_mean_by" + [139] "rolling_median" "rolling_median_by" "rolling_min" + [142] "rolling_min_by" "rolling_quantile" "rolling_quantile_by" + [145] "rolling_skew" "rolling_std" "rolling_std_by" + [148] "rolling_sum" "rolling_sum_by" "rolling_var" + [151] "rolling_var_by" "round" "sample" + [154] "search_sorted" "set_sorted" "shift" + [157] "shift_and_fill" "shrink_dtype" "shuffle" + [160] "sign" "sin" "sinh" + [163] "skew" "slice" "sort" + [166] "sort_by" "sqrt" "std" + [169] "str" "struct" "sub" + [172] "sum" "tail" "tan" + [175] "tanh" "to_physical" "to_r" + [178] "to_series" "top_k" "unique" + [181] "unique_counts" "upper_bound" "value_counts" + [184] "var" "when" "xor" --- @@ -556,67 +559,68 @@ Code ls(.pr$env[[class_name]]) Output - [1] "abs" "add" "agg_groups" - [4] "alias" "all" "and" - [7] "any" "append" "approx_n_unique" - [10] "arccos" "arccosh" "arcsin" - [13] "arcsinh" "arctan" "arctanh" - [16] "arg_max" "arg_min" "arg_sort" - [19] "arg_unique" "arr" "backward_fill" - [22] "bin" "bottom_k" "cast" - [25] "cat" "ceil" "clip" - [28] "clip_max" "clip_min" "cos" - [31] "cosh" "count" "cum_count" - [34] "cum_max" "cum_min" "cum_prod" - [37] "cum_sum" "cumulative_eval" "cut" - [40] "diff" "div" "dot" - [43] "drop_nans" "drop_nulls" "dt" - [46] "entropy" "eq" "eq_missing" - [49] "ewm_mean" "ewm_std" "ewm_var" - [52] "exclude" "exp" "explode" - [55] "extend_constant" "fill_nan" "fill_null" - [58] "filter" "first" "flatten" - [61] "floor" "floor_div" "forward_fill" - [64] "gather" "gather_every" "gt" - [67] "gt_eq" "hash" "head" - [70] "implode" "inspect" "interpolate" - [73] "is_between" "is_duplicated" "is_finite" - [76] "is_first_distinct" "is_in" "is_infinite" - [79] "is_last_distinct" "is_nan" "is_not_nan" - [82] "is_not_null" "is_null" "is_unique" - [85] "kurtosis" "last" "len" - [88] "limit" "list" "log" - [91] "log10" "lower_bound" "lt" - [94] "lt_eq" "map_batches" "map_elements" - [97] "max" "mean" "median" - [100] "meta" "min" "mod" - [103] "mode" "mul" "n_unique" - [106] "name" "nan_max" "nan_min" - [109] "neq" "neq_missing" "not" - [112] "null_count" "or" "otherwise" - [115] "over" "pct_change" "peak_max" - [118] "peak_min" "pow" "print" - [121] "product" "qcut" "quantile" - [124] "rank" "rechunk" "reinterpret" - [127] "rep" "repeat_by" "replace" - [130] "reshape" "reverse" "rle" - [133] "rle_id" "rolling" "rolling_max" - [136] "rolling_max_by" "rolling_mean" "rolling_mean_by" - [139] "rolling_median" "rolling_median_by" "rolling_min" - [142] "rolling_min_by" "rolling_quantile" "rolling_skew" - [145] "rolling_std" "rolling_sum" "rolling_sum_by" - [148] "rolling_var" "round" "sample" - [151] "search_sorted" "set_sorted" "shift" - [154] "shift_and_fill" "shrink_dtype" "shuffle" - [157] "sign" "sin" "sinh" - [160] "skew" "slice" "sort" - [163] "sort_by" "sqrt" "std" - [166] "str" "struct" "sub" - [169] "sum" "tail" "tan" - [172] "tanh" "to_physical" "to_r" - [175] "to_series" "top_k" "unique" - [178] "unique_counts" "upper_bound" "value_counts" - [181] "var" "when" "xor" + [1] "abs" "add" "agg_groups" + [4] "alias" "all" "and" + [7] "any" "append" "approx_n_unique" + [10] "arccos" "arccosh" "arcsin" + [13] "arcsinh" "arctan" "arctanh" + [16] "arg_max" "arg_min" "arg_sort" + [19] "arg_unique" "arr" "backward_fill" + [22] "bin" "bottom_k" "cast" + [25] "cat" "ceil" "clip" + [28] "clip_max" "clip_min" "cos" + [31] "cosh" "count" "cum_count" + [34] "cum_max" "cum_min" "cum_prod" + [37] "cum_sum" "cumulative_eval" "cut" + [40] "diff" "div" "dot" + [43] "drop_nans" "drop_nulls" "dt" + [46] "entropy" "eq" "eq_missing" + [49] "ewm_mean" "ewm_std" "ewm_var" + [52] "exclude" "exp" "explode" + [55] "extend_constant" "fill_nan" "fill_null" + [58] "filter" "first" "flatten" + [61] "floor" "floor_div" "forward_fill" + [64] "gather" "gather_every" "gt" + [67] "gt_eq" "hash" "head" + [70] "implode" "inspect" "interpolate" + [73] "is_between" "is_duplicated" "is_finite" + [76] "is_first_distinct" "is_in" "is_infinite" + [79] "is_last_distinct" "is_nan" "is_not_nan" + [82] "is_not_null" "is_null" "is_unique" + [85] "kurtosis" "last" "len" + [88] "limit" "list" "log" + [91] "log10" "lower_bound" "lt" + [94] "lt_eq" "map_batches" "map_elements" + [97] "max" "mean" "median" + [100] "meta" "min" "mod" + [103] "mode" "mul" "n_unique" + [106] "name" "nan_max" "nan_min" + [109] "neq" "neq_missing" "not" + [112] "null_count" "or" "otherwise" + [115] "over" "pct_change" "peak_max" + [118] "peak_min" "pow" "print" + [121] "product" "qcut" "quantile" + [124] "rank" "rechunk" "reinterpret" + [127] "rep" "repeat_by" "replace" + [130] "reshape" "reverse" "rle" + [133] "rle_id" "rolling" "rolling_max" + [136] "rolling_max_by" "rolling_mean" "rolling_mean_by" + [139] "rolling_median" "rolling_median_by" "rolling_min" + [142] "rolling_min_by" "rolling_quantile" "rolling_quantile_by" + [145] "rolling_skew" "rolling_std" "rolling_std_by" + [148] "rolling_sum" "rolling_sum_by" "rolling_var" + [151] "rolling_var_by" "round" "sample" + [154] "search_sorted" "set_sorted" "shift" + [157] "shift_and_fill" "shrink_dtype" "shuffle" + [160] "sign" "sin" "sinh" + [163] "skew" "slice" "sort" + [166] "sort_by" "sqrt" "std" + [169] "str" "struct" "sub" + [172] "sum" "tail" "tan" + [175] "tanh" "to_physical" "to_r" + [178] "to_series" "top_k" "unique" + [181] "unique_counts" "upper_bound" "value_counts" + [184] "var" "when" "xor" --- @@ -645,70 +649,71 @@ Code ls(.pr$env[[class_name]]) Output - [1] "abs" "add" "alias" - [4] "all" "and" "any" - [7] "append" "approx_n_unique" "arccos" - [10] "arccosh" "arcsin" "arcsinh" - [13] "arctan" "arctanh" "arg_max" - [16] "arg_min" "arg_sort" "arg_unique" - [19] "arr" "backward_fill" "bin" - [22] "bottom_k" "cast" "cat" - [25] "ceil" "chunk_lengths" "clear" - [28] "clip" "clip_max" "clip_min" - [31] "clone" "compare" "cos" - [34] "cosh" "count" "cum_count" - [37] "cum_max" "cum_min" "cum_prod" - [40] "cum_sum" "cumulative_eval" "cut" - [43] "diff" "div" "dot" - [46] "drop_nans" "drop_nulls" "dt" - [49] "dtype" "entropy" "eq" - [52] "eq_missing" "equals" "ewm_mean" - [55] "ewm_std" "ewm_var" "exp" - [58] "explode" "extend_constant" "fill_nan" - [61] "fill_null" "filter" "first" - [64] "flags" "flatten" "floor" - [67] "floor_div" "forward_fill" "gather" - [70] "gather_every" "gt" "gt_eq" - [73] "hash" "head" "implode" - [76] "interpolate" "is_between" "is_duplicated" - [79] "is_finite" "is_first_distinct" "is_in" - [82] "is_infinite" "is_last_distinct" "is_nan" - [85] "is_not_nan" "is_not_null" "is_null" - [88] "is_numeric" "is_sorted" "is_unique" - [91] "item" "kurtosis" "last" - [94] "len" "limit" "list" - [97] "log" "log10" "lower_bound" - [100] "lt" "lt_eq" "map_batches" - [103] "map_elements" "max" "mean" - [106] "median" "min" "mod" - [109] "mode" "mul" "n_chunks" - [112] "n_unique" "name" "nan_max" - [115] "nan_min" "neq" "neq_missing" - [118] "not" "null_count" "or" - [121] "pct_change" "peak_max" "peak_min" - [124] "pow" "print" "product" - [127] "qcut" "quantile" "rank" - [130] "rechunk" "reinterpret" "rename" - [133] "rep" "repeat_by" "replace" - [136] "reshape" "reverse" "rle" - [139] "rle_id" "rolling_max" "rolling_max_by" - [142] "rolling_mean" "rolling_mean_by" "rolling_median" - [145] "rolling_median_by" "rolling_min" "rolling_min_by" - [148] "rolling_quantile" "rolling_skew" "rolling_std" - [151] "rolling_sum" "rolling_sum_by" "rolling_var" - [154] "round" "sample" "search_sorted" - [157] "set_sorted" "shape" "shift" - [160] "shift_and_fill" "shrink_dtype" "shuffle" - [163] "sign" "sin" "sinh" - [166] "skew" "slice" "sort" - [169] "sort_by" "sqrt" "std" - [172] "str" "struct" "sub" - [175] "sum" "tail" "tan" - [178] "tanh" "to_frame" "to_list" - [181] "to_lit" "to_physical" "to_r" - [184] "to_vector" "top_k" "unique" - [187] "unique_counts" "upper_bound" "value_counts" - [190] "var" "xor" + [1] "abs" "add" "alias" + [4] "all" "and" "any" + [7] "append" "approx_n_unique" "arccos" + [10] "arccosh" "arcsin" "arcsinh" + [13] "arctan" "arctanh" "arg_max" + [16] "arg_min" "arg_sort" "arg_unique" + [19] "arr" "backward_fill" "bin" + [22] "bottom_k" "cast" "cat" + [25] "ceil" "chunk_lengths" "clear" + [28] "clip" "clip_max" "clip_min" + [31] "clone" "compare" "cos" + [34] "cosh" "count" "cum_count" + [37] "cum_max" "cum_min" "cum_prod" + [40] "cum_sum" "cumulative_eval" "cut" + [43] "diff" "div" "dot" + [46] "drop_nans" "drop_nulls" "dt" + [49] "dtype" "entropy" "eq" + [52] "eq_missing" "equals" "ewm_mean" + [55] "ewm_std" "ewm_var" "exp" + [58] "explode" "extend_constant" "fill_nan" + [61] "fill_null" "filter" "first" + [64] "flags" "flatten" "floor" + [67] "floor_div" "forward_fill" "gather" + [70] "gather_every" "gt" "gt_eq" + [73] "hash" "head" "implode" + [76] "interpolate" "is_between" "is_duplicated" + [79] "is_finite" "is_first_distinct" "is_in" + [82] "is_infinite" "is_last_distinct" "is_nan" + [85] "is_not_nan" "is_not_null" "is_null" + [88] "is_numeric" "is_sorted" "is_unique" + [91] "item" "kurtosis" "last" + [94] "len" "limit" "list" + [97] "log" "log10" "lower_bound" + [100] "lt" "lt_eq" "map_batches" + [103] "map_elements" "max" "mean" + [106] "median" "min" "mod" + [109] "mode" "mul" "n_chunks" + [112] "n_unique" "name" "nan_max" + [115] "nan_min" "neq" "neq_missing" + [118] "not" "null_count" "or" + [121] "pct_change" "peak_max" "peak_min" + [124] "pow" "print" "product" + [127] "qcut" "quantile" "rank" + [130] "rechunk" "reinterpret" "rename" + [133] "rep" "repeat_by" "replace" + [136] "reshape" "reverse" "rle" + [139] "rle_id" "rolling_max" "rolling_max_by" + [142] "rolling_mean" "rolling_mean_by" "rolling_median" + [145] "rolling_median_by" "rolling_min" "rolling_min_by" + [148] "rolling_quantile" "rolling_quantile_by" "rolling_skew" + [151] "rolling_std" "rolling_std_by" "rolling_sum" + [154] "rolling_sum_by" "rolling_var" "rolling_var_by" + [157] "round" "sample" "search_sorted" + [160] "set_sorted" "shape" "shift" + [163] "shift_and_fill" "shrink_dtype" "shuffle" + [166] "sign" "sin" "sinh" + [169] "skew" "slice" "sort" + [172] "sort_by" "sqrt" "std" + [175] "str" "struct" "sub" + [178] "sum" "tail" "tan" + [181] "tanh" "to_frame" "to_list" + [184] "to_lit" "to_physical" "to_r" + [187] "to_vector" "top_k" "unique" + [190] "unique_counts" "upper_bound" "value_counts" + [193] "var" "xor" --- diff --git a/tests/testthat/test-expr_expr.R b/tests/testthat/test-expr_expr.R index 416b9852b..16c1acd29 100644 --- a/tests/testthat/test-expr_expr.R +++ b/tests/testthat/test-expr_expr.R @@ -1677,10 +1677,10 @@ test_that("Expr_rolling_*_by", { max = 1:6, mean = c(1, 1.5, 2.5, 3.5, 4.5, 5.5), sum = c(1L, 3L, 5L, 7L, 9L, 11L), - # std = c(NA, rep(0.7071067811865476, 5)), - # var = c(NA, rep(0.5, 5)), - median = c(1, 1.5, 2.5, 3.5, 4.5, 5.5) - # quantile_linear = c(NA, 1.33, 2.33, 3.33, 4.33, 5.33) + std = c(NA, rep(0.7071067811865476, 5)), + var = c(NA, rep(0.5, 5)), + median = c(1, 1.5, 2.5, 3.5, 4.5, 5.5), + quantile_linear = c(1, 1.33, 2.33, 3.33, 4.33, 5.33) ) expect_identical( @@ -1689,12 +1689,12 @@ test_that("Expr_rolling_*_by", { pl$col("a")$rolling_max_by("date", window_size = "2d")$alias("max"), pl$col("a")$rolling_mean_by("date", window_size = "2d")$alias("mean"), pl$col("a")$rolling_sum_by("date", window_size = "2d")$alias("sum"), - # pl$col("a")$rolling_std("date", window_size = "2d")$alias("std"), - # pl$col("a")$rolling_var("date", window_size = "2d")$alias("var"), - pl$col("a")$rolling_median_by("date", window_size = "2d")$alias("median") - # pl$col("a")$rolling_quantile( - # quantile = .33, "date", window_size = "2d", interpolation = "linear" - # )$alias("quantile_linear") + pl$col("a")$rolling_std_by("date", window_size = "2d")$alias("std"), + pl$col("a")$rolling_var_by("date", window_size = "2d")$alias("var"), + pl$col("a")$rolling_median_by("date", window_size = "2d")$alias("median"), + pl$col("a")$rolling_quantile_by( + quantile = .33, "date", window_size = "2d", interpolation = "linear" + )$alias("quantile_linear") )$to_data_frame(), expected ) @@ -1725,10 +1725,10 @@ test_that("Expr_rolling_*_by: arg 'min_periods'", { max = c(NA_integer_, 2L:6L), mean = c(NA, 1.5, 2.5, 3.5, 4.5, 5.5), sum = c(NA_integer_, 3L, 5L, 7L, 9L, 11L), - # std = c(NA, rep(0.7071067811865476, 5)), - # var = c(NA, rep(0.5, 5)), - median = c(NA, 1.5, 2.5, 3.5, 4.5, 5.5) - # quantile_linear = c(NA, 1.33, 2.33, 3.33, 4.33, 5.33) + std = c(NA, rep(0.7071067811865476, 5)), + var = c(NA, rep(0.5, 5)), + median = c(NA, 1.5, 2.5, 3.5, 4.5, 5.5), + quantile_linear = c(NA, 1.33, 2.33, 3.33, 4.33, 5.33) ) expect_identical( @@ -1737,12 +1737,12 @@ test_that("Expr_rolling_*_by: arg 'min_periods'", { pl$col("a")$rolling_max_by("date", window_size = "2d", min_periods = 2)$alias("max"), pl$col("a")$rolling_mean_by("date", window_size = "2d", min_periods = 2)$alias("mean"), pl$col("a")$rolling_sum_by("date", window_size = "2d", min_periods = 2)$alias("sum"), - # pl$col("a")$rolling_std("date", window_size = "2d", min_periods = 2)$alias("std"), - # pl$col("a")$rolling_var("date", window_size = "2d", min_periods = 2)$alias("var"), - pl$col("a")$rolling_median_by("date", window_size = "2d", min_periods = 2)$alias("median") - # pl$col("a")$rolling_quantile( - # quantile = .33, "date", window_size = "2d", min_periods = 2, interpolation = "linear" - # )$alias("quantile_linear") + pl$col("a")$rolling_std_by("date", window_size = "2d", min_periods = 2)$alias("std"), + pl$col("a")$rolling_var_by("date", window_size = "2d", min_periods = 2)$alias("var"), + pl$col("a")$rolling_median_by("date", window_size = "2d", min_periods = 2)$alias("median"), + pl$col("a")$rolling_quantile_by( + quantile = .33, "date", window_size = "2d", min_periods = 2, interpolation = "linear" + )$alias("quantile_linear") )$to_data_frame(), expected ) @@ -1764,10 +1764,10 @@ test_that("Expr_rolling_*_by: arg 'closed'", { max = c(NA_integer_, 1:5), mean = c(NA, 1, 1.5, 2.5, 3.5, 4.5), sum = c(NA, 1L, 3L, 5L, 7L, 9L), - # std = c(NA, rep(0.7071067811865476, 5)), - # var = c(NA, rep(0.5, 5)), - median = c(NA, 1, 1.5, 2.5, 3.5, 4.5) - # quantile_linear = c(NA, 1.33, 2.33, 3.33, 4.33, 5.33) + std = c(NA, NA, rep(0.7071067811865476, 4)), + var = c(NA, NA, rep(0.5, 4)), + median = c(NA, 1, 1.5, 2.5, 3.5, 4.5), + quantile_linear = c(NA, 1.00, 1.33, 2.33, 3.33, 4.33) ) expect_identical( @@ -1776,12 +1776,12 @@ test_that("Expr_rolling_*_by: arg 'closed'", { pl$col("a")$rolling_max_by("date", window_size = "2d", closed = "left")$alias("max"), pl$col("a")$rolling_mean_by("date", window_size = "2d", closed = "left")$alias("mean"), pl$col("a")$rolling_sum_by("date", window_size = "2d", closed = "left")$alias("sum"), - # pl$col("a")$rolling_std("date", window_size = "2d", closed = "left")$alias("std"), - # pl$col("a")$rolling_var("date", window_size = "2d", closed = "left")$alias("var"), - pl$col("a")$rolling_median_by("date", window_size = "2d", closed = "left")$alias("median") - # pl$col("a")$rolling_quantile( - # quantile = .33, "date", window_size = "2d", closed = "left", interpolation = "linear" - # )$alias("quantile_linear") + pl$col("a")$rolling_std_by("date", window_size = "2d", closed = "left")$alias("std"), + pl$col("a")$rolling_var_by("date", window_size = "2d", closed = "left")$alias("var"), + pl$col("a")$rolling_median_by("date", window_size = "2d", closed = "left")$alias("median"), + pl$col("a")$rolling_quantile_by( + quantile = .33, "date", window_size = "2d", closed = "left", interpolation = "linear" + )$alias("quantile_linear") )$to_data_frame(), expected )