Clip (limit) the values in an array to any value that fits in 64 floating point range. Only works for the following dtypes: {Int32, Int64, Float32, Float64, UInt32}. If you want to clip other dtypes, consider writing a when -> then -> otherwise expression
Minimum value
Maximum value
Sample from this DataFrame by setting either n
or frac
.
Optional
n: numberNumber of samples < self.len() .
Optional
frac: numberFraction between 0.0 and 1.0 .
Optional
withReplacement: booleanSample with replacement.
Optional
seed: number | bigintSeed initialization. If not provided, a random seed will be used
Get the index of the maximal value.
Get the index of the minimal value.
Get the length of each individual chunk
__Quick summary statistics of a series. __
Series with mixed datatypes will return summary statistics for the datatype of the first value.
> const seriesNum = pl.Series([1,2,3,4,5])
> series_num.describe()
shape: (6, 2)
┌──────────────┬────────────────────┐
│ statistic ┆ value │
│ --- ┆ --- │
│ str ┆ f64 │
╞══════════════╪════════════════════╡
│ "min" ┆ 1 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ "max" ┆ 5 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ "null_count" ┆ 0.0 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ "mean" ┆ 3 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ "std" ┆ 1.5811388300841898 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ "count" ┆ 5 │
└──────────────┴────────────────────┘
> series_str = pl.Series(["a", "a", None, "b", "c"])
> series_str.describe()
shape: (3, 2)
┌──────────────┬───────┐
│ statistic ┆ value │
│ --- ┆ --- │
│ str ┆ i64 │
╞══════════════╪═══════╡
│ "unique" ┆ 4 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ "null_count" ┆ 1 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ "count" ┆ 5 │
└──────────────┴───────┘
Exponentially-weighted moving average.
Optional
alpha: numberSpecify smoothing factor alpha directly, :math:0 < \alpha \leq 1
.
Optional
adjust: booleanDivide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings
- When adjust: true
the EW function is calculated using weights :math:w_i = (1 - \alpha)^i
- When adjust=false
the EW function is calculated recursively
Optional
minPeriods: numberMinimum number of observations in window required to have a value (otherwise result is null).
Optional
bias: booleanWhen bias: false
, apply a correction to make the estimate statistically unbiased.
Optional
ignoreNulls: booleanIgnore missing values when calculating weights.
- When ignoreNulls: false
(default), weights are based on absolute positions.
- When ignoreNulls: true
, weights are based on relative positions.
Expr that evaluates to a float 64 Series.
Exponentially-weighted standard deviation.
Optional
alpha: numberSpecify smoothing factor alpha directly, :math:0 < \alpha \leq 1
.
Optional
adjust: booleanDivide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings
- When adjust: true
the EW function is calculated using weights :math:w_i = (1 - \alpha)^i
- When adjust: false
the EW function is calculated recursively
Optional
minPeriods: numberMinimum number of observations in window required to have a value (otherwise result is null).
Optional
bias: booleanWhen bias: false
, apply a correction to make the estimate statistically unbiased.
Optional
ignoreNulls: booleanIgnore missing values when calculating weights.
- When ignoreNulls: false
(default), weights are based on absolute positions.
For example, the weights of :math:x_0
and :math:x_2
used in calculating the final weighted average of
- When ignoreNulls: true
, weights are based on relative positions.
Expr that evaluates to a float 64 Series.
Exponentially-weighted variance.
Optional
alpha: numberSpecify smoothing factor alpha directly, :math:0 < \alpha \leq 1
.
Optional
adjust: booleanDivide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings
- When adjust: true
the EW function is calculated using weights :math:w_i = (1 - \alpha)^i
- When adjust: false
the EW function is calculated recursively
Optional
minPeriods: numberMinimum number of observations in window required to have a value (otherwise result is null).
Optional
bias: booleanWhen bias: false
, apply a correction to make the estimate statistically unbiased.
Optional
ignoreNulls: booleanIgnore missing values when calculating weights.
- When ignoreNulls: false
(default), weights are based on absolute positions.
- When ignoreNulls=true
, weights are based on relative positions.
Expr that evaluates to a float 64 Series.
Returns True if the Series has a validity bitmask. If there is none, it means that there are no null values.
Interpolate intermediate values.
The interpolation method is linear.
Optional
method: InterpolationMethodCheck if this Series is a Boolean.
Check if this Series is a DataTime.
Check if this Series is a Float.
Check if this Series datatype is numeric.
Checks if this Series datatype is a String.
Compute the kurtosis (Fisher or Pearson) of a dataset.
Kurtosis is the fourth central moment divided by the square of the variance. If Fisher's definition is used, then 3.0 is subtracted from the result to give 0.0 for a normal distribution. If bias is False then the kurtosis is calculated using k statistics to eliminate bias coming from biased moment estimators
If True, Fisher's definition is used (normal ==> 0.0).
Optional
bias: boolean: bool, optional If False, the calculations are corrected for statistical bias.
Get the number of chunks that this Series contains.
Count the null values in this Series. --
undefined
values are treated as null
Assign ranks to data, dealing with ties appropriately. The method used to assign ranks to tied elements.
Optional
method: RankMethod{'average', 'min', 'max', 'dense', 'ordinal', 'random'} The following methods are available: default is 'average'
a
.a
.Optional
descending: booleanRank in descending order.
Shrink memory usage of this Series to fit the exact capacity needed to hold the data.
Modify the Series in-place.
Compute the sample skewness of a data set.
For normally distributed data, the skewness should be about zero. For
unimodal continuous distributions, a skewness value greater than zero means
that there is more weight in the right tail of the distribution. The
function skewtest
can be used to determine if the skewness value
is close enough to zero, statistically speaking.
Optional
bias: booleanIf false, then the calculations are corrected for statistical bias.
Convert this Series to a Javascript Array.
This operation clones data, and is very slow, but maintains greater precision for all dtypes.
Often times series.toObject().values
is faster, but less precise
Get dummy/indicator variables.
Optional
separator: stringstr = "_",
Optional
dropFirst: booleanbool = False
const s = pl.Series("a", [1, 2, 3])
>>> s.toDummies()
shape: (3, 3)
┌─────┬─────┬─────┐
│ a_1 ┆ a_2 ┆ a_3 │
│ --- ┆ --- ┆ --- │
│ u8 ┆ u8 ┆ u8 │
╞═════╪═════╪═════╡
│ 1 ┆ 0 ┆ 0 │
│ 0 ┆ 1 ┆ 0 │
│ 0 ┆ 0 ┆ 1 │
└─────┴─────┴─────┘
>>> s.toDummies(":", true)
shape: (3, 2)
┌─────┬─────┐
│ a:2 ┆ a:3 │
│ --- ┆ --- │
│ u8 ┆ u8 │
╞═════╪═════╡
│ 0 ┆ 0 │
│ 1 ┆ 0 │
│ 0 ┆ 1 │
└─────┴─────┘
compat with `JSON.stringify
Converts series to a javascript typedArray.
Warning: This will throw an error if you have nulls, or are using non numeric data types
Count the unique values in a Series.
Optional
sort: booleanSort the output by count in descending order.
If set to False
(default), the order of the output is random.
Optional
parallel: booleanExecute the computation in parallel. .. note:: This option should likely not be enabled in a group by context, as the computation is already parallelized per group.
Optional
name: stringGive the resulting count column a specific name;
if normalize
is True defaults to "count", otherwise defaults to "proportion".
Optional
normalize: booleanIf true gives relative frequencies of the unique values
Returns an iterator over the values
Apply a rolling max (moving max) over the values in this Series.
A window of length window_size
will traverse the series. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector.
The resulting parameters' values will be aggregated into their sum.
The length of the window.
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Apply a rolling mean (moving mean) over the values in this Series.
A window of length window_size
will traverse the series. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector.
The resulting parameters' values will be aggregated into their sum.
The length of the window.
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Apply a rolling min (moving min) over the values in this Series.
A window of length window_size
will traverse the series. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector.
The resulting parameters' values will be aggregated into their sum.
The length of the window.
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Compute a rolling quantile
quantile to compute
Optional
interpolation: InterpolationMethodinterpolation type
Optional
windowSize: numberSize of the rolling window
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Optional
by: stringOptional
closed: ClosedWindowCompute a rolling skew
options for rolling mean operations
Optional
bias?: booleanCompute a rolling std dev
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 weight
vector. The resulting
values will be aggregated to their sum.
The length of the window.
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Optional
ddof: number"Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof, where N represents the number of elements. By default ddof is 1.
Apply a rolling sum (moving sum) over the values in this Series.
A window of length window_size
will traverse the series. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector.
The resulting parameters' values will be aggregated into their sum.
The length of the window.
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Compute a rolling variance.
A window of length window_size
will traverse the series. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector.
The resulting parameters' values will be aggregated into their sum.
The length of the window.
Optional
weights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
Optional
minPeriods: number[]The number of values in the window that should be non-null before computing a result. If undefined, it will be set equal to window size.
Optional
center: booleanSet the labels at the center of the window
Optional
ddof: number"Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof, where N represents the number of elements. By default ddof is 1.
A Series represents a single column in a polars DataFrame.