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
Round underlying floating point data by decimals digits.
Similar functionality to javascript toFixed
number of decimals to round by.
Optionalmode: RoundModeRounding mode, the default is "half to even" (also known as "bankers' rounding"). RoundMode. * halftoeven round to the nearest even number * halfawayfromzero round to the nearest number away from zero
Sample from this DataFrame by setting either n or frac.
Optionaln: numberNumber of samples < self.len() .
Optionalfrac: numberFraction between 0.0 and 1.0 .
OptionalwithReplacement: booleanSample with replacement.
Optionalseed: number | bigintSeed initialization. If not provided, a random seed will be used
Get the index of the maximal 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.
Optionalalpha: numberSpecify smoothing factor alpha directly, :math:0 < \alpha \leq 1.
Optionaladjust: 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
OptionalminPeriods: numberMinimum number of observations in window required to have a value (otherwise result is null).
Optionalbias: booleanWhen bias: false, apply a correction to make the estimate statistically unbiased.
OptionalignoreNulls: 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.
Optionalalpha: numberSpecify smoothing factor alpha directly, :math:0 < \alpha \leq 1.
Optionaladjust: 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
OptionalminPeriods: numberMinimum number of observations in window required to have a value (otherwise result is null).
Optionalbias: booleanWhen bias: false, apply a correction to make the estimate statistically unbiased.
OptionalignoreNulls: 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.
Optionalalpha: numberSpecify smoothing factor alpha directly, :math:0 < \alpha \leq 1.
Optionaladjust: 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
OptionalminPeriods: numberMinimum number of observations in window required to have a value (otherwise result is null).
Optionalbias: booleanWhen bias: false, apply a correction to make the estimate statistically unbiased.
OptionalignoreNulls: 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.
Optionalmethod: InterpolationMethodCheck if this Series is a DataTime.
Check if this Series is a Float.
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).
Optionalbias: 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.
Optionalmethod: RankMethod{'average', 'min', 'max', 'dense', 'ordinal', 'random'} The following methods are available: default is 'average'
a.a.Optionaldescending: 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.
Optionalbias: booleanIf false, then the calculations are corrected for statistical bias.
Get dummy/indicator variables.
Optionalseparator: stringstr = "_",
OptionaldropFirst: booleanbool = False
OptionaldropNulls: 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
Returns a Javascript object representation of Series
Often this is much faster than the iterator, or values method
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.
Optionalsort: booleanSort the output by count in descending order.
If set to False (default), the order of the output is random.
Optionalparallel: 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.
Optionalname: stringGive the resulting count column a specific name;
if normalize is True defaults to "count", otherwise defaults to "proportion".
Optionalnormalize: 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.
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: 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.
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: 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.
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: booleanSet the labels at the center of the window
Compute a rolling quantile
quantile to compute
Optionalinterpolation: InterpolationMethodinterpolation type
OptionalwindowSize: numberSize of the rolling window
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: booleanSet the labels at the center of the window
Optionalby: stringOptionalclosed: ClosedWindowCompute a rolling skew
options for rolling mean operations
Optionalbias?: 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.
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: booleanSet the labels at the center of the window
Optionalddof: 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.
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: 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.
Optionalweights: number[]An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
OptionalminPeriods: 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.
Optionalcenter: booleanSet the labels at the center of the window
Optionalddof: 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.