Apply a rolling skew over values
Description
A window of length window_size
will traverse the array. The
values that fill this window will (optionally) be multiplied with the
weights given by the weights
vector. The resulting values
will be aggregated.
The window at a given row will include the row itself, and the
window_size - 1
elements before it.
Usage
<Expr>$rolling_skew(
window_size,
...,
bias = TRUE,
min_samples = NULL,
center = FALSE
)
Arguments
window_size
|
The length of the window in number of elements. |
…
|
These dots are for future extensions and must be empty. |
bias
|
If FALSE , the calculations are corrected for statistical
bias.
|
min_samples
|
The number of values in the window that should be non-null before
computing a result. If set to NULL (default), it will be
set equal to window_size .
|
center
|
Set the labels at the center of the window. |
Details
If you want to compute multiple aggregation statistics over the same
dynamic window, consider using $rolling()
- this method can
cache the window size computation.
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, 4, 2, 9))
df$with_columns(
rolling_skew = pl$col("a")$rolling_skew(3)
)
#> shape: (4, 2)
#> ┌─────┬──────────────┐
#> │ a ┆ rolling_skew │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪══════════════╡
#> │ 1.0 ┆ null │
#> │ 4.0 ┆ null │
#> │ 2.0 ┆ 0.381802 │
#> │ 9.0 ┆ 0.47033 │
#> └─────┴──────────────┘