# Functions#

These functions are available from the polars module root and can be used as expressions, and sometimes also in eager contexts.

Available in module namespace:

 `all`(*names[, ignore_nulls]) Either return an expression representing all columns, or evaluate a bitwise AND operation. `all_horizontal`(*exprs) Compute the bitwise AND horizontally across columns. `any`(*names[, ignore_nulls]) Evaluate a bitwise OR operation. `any_horizontal`(*exprs) Compute the bitwise OR horizontally across columns. `apply`(exprs, function[, return_dtype, ...]) Apply a custom/user-defined function (UDF) in a GroupBy context. `approx_n_unique`(column) Approximate count of unique values. Generate a range of integers. `arctan2`(y, x) Compute two argument arctan in radians. `arctan2d`(y, x) Compute two argument arctan in degrees. `arg_sort_by`(exprs, *more_exprs[, descending]) Return the row indices that would sort the columns. Return indices where condition evaluates True. Alias for mean. `coalesce`(exprs, *more_exprs) Folds the columns from left to right, keeping the first non-null value. `concat_list`(exprs, *more_exprs) Horizontally concatenate columns into a single list column. `concat_str`(exprs, *more_exprs[, separator]) Horizontally concatenate columns into a single string column. `corr`(a, b, *[, method, ddof, propagate_nans]) Compute the Pearson's or Spearman rank correlation correlation between two columns. Count the number of values in this column/context. `cov`(a, b) Compute the covariance between two columns/ expressions. `cumfold`(acc, function, exprs, *[, include_init]) Cumulatively accumulate over multiple columns horizontally/ row wise with a left fold. `cumreduce`(function, exprs) Cumulatively accumulate over multiple columns horizontally/ row wise with a left fold. `cumsum`(*names) Cumulatively sum all values. `cumsum_horizontal`(*exprs) Cumulatively sum all values horizontally across columns. `date`(year, month, day) Create a Polars literal expression of type Date. `datetime`(year, month, day[, hour, minute, ...]) Create a Polars literal expression of type Datetime. Generate a date range. Create a column of date ranges. Generate a datetime range. Create a column of datetime ranges. `duration`(*[, days, seconds, nanoseconds, ...]) Create polars Duration from distinct time components. Alias for an element being evaluated in an eval expression. `exclude`(columns, *more_columns) Represent all columns except for the given columns. Get the first value. `fold`(acc, function, exprs) Accumulate over multiple columns horizontally/ row wise with a left fold. `format`(f_string, *args) Format expressions as a string. Utility function that parses an epoch timestamp (or Unix time) to Polars Date(time). `groups`(column) Syntactic sugar for pl.col("foo").agg_groups(). Get the first n rows. `implode`(name) Aggregate all column values into a list. Generate a range of integers. Generate a range of integers for each row of the input columns. Get the last value. `lit`(value[, dtype, allow_object]) Return an expression representing a literal value. `map`(exprs, function[, return_dtype]) Map a custom function over multiple columns/expressions. `map_batches`(exprs, function[, return_dtype]) Map a custom function over multiple columns/expressions. `map_groups`(exprs, function[, return_dtype, ...]) Apply a custom/user-defined function (UDF) in a GroupBy context. `max`(*names) Get the maximum value. `max_horizontal`(*exprs) Get the maximum value horizontally across columns. Get the mean value. Get the median value. `min`(*names) Get the minimum value. `min_horizontal`(*exprs) Get the minimum value horizontally across columns. Count unique values. Construct a column of length n filled with ones. `quantile`(column, quantile[, interpolation]) Syntactic sugar for pl.col("foo").quantile(..). `reduce`(function, exprs) Accumulate over multiple columns horizontally/ row wise with a left fold. Construct a column of length n filled with the given value. `rolling_corr`(a, b, *, window_size[, ...]) Compute the rolling correlation between two columns/ expressions. `rolling_cov`(a, b, *, window_size[, ...]) Compute the rolling covariance between two columns/ expressions. `select`(*exprs, **named_exprs) Run polars expressions without a context. Get the standard deviation. Collect columns into a struct column. `sum`(*names) Sum all values. `sum_horizontal`(*exprs) Sum all values horizontally across columns. Parse one or more SQL expressions to polars expression(s). Get the last n rows. `time`([hour, minute, second, microsecond]) Create a Polars literal expression of type Time. Generate a time range. Create a column of time ranges. Get the variance. `when`(condition) Start a when-then-otherwise expression. Construct a column of length n filled with zeros.

Available in expression namespace:

 `Expr.all`(*[, ignore_nulls]) Return whether all values in the column are `True`. `Expr.any`(*[, ignore_nulls]) Return whether any of the values in the column are `True`. `Expr.apply`(function[, return_dtype, ...]) Apply a custom/user-defined function (UDF) in a GroupBy or Projection context. Approximate count of unique values. Count the number of values in this expression. `Expr.cumsum`(*[, reverse]) Get an array with the cumulative sum computed at every element. `Expr.exclude`(columns, *more_columns) Exclude columns from a multi-column expression. Get the first value. `Expr.head`([n]) Get the first n rows. Aggregate values into a list. `Expr.map`(function[, return_dtype, agg_list]) Apply a custom python function to a Series or sequence of Series. `Expr.map_batches`(function[, return_dtype, ...]) Apply a custom python function to a whole Series or sequence of Series. `Expr.map_elements`(function[, return_dtype, ...]) Map a custom/user-defined function (UDF) to each element of a column. Get maximum value. Get mean value. Get median value using linear interpolation. Get minimum value. Count unique values. `Expr.quantile`(quantile[, interpolation]) Get quantile value. `Expr.std`([ddof]) Get standard deviation. Get sum value. `Expr.tail`([n]) Get the last n rows. `Expr.var`([ddof]) Get variance.