Bulk column selection
Apply the same expression to every column in a DataFrame selection.
Polars · Function
pl.all returns an expression selecting all columns when called without arguments, or processes supplied inputs. Horizontal bitwise-AND behavior is deprecated; use pl.all_horizontal for new code.
With no arguments, pl.all() creates an expression matching every column, so column expressions such as sum() are applied to each selected column. Passing expressions or names instead supports aggregation over specified inputs, but horizontal bitwise-AND aggregation is deprecated in favor of pl.all_horizontal.
polars.all(*exprs: IntoExpr | Iterable[IntoExpr] | None = None, **more_exprs: IntoExpr) -> Expr| Name | Type | Description |
|---|---|---|
exprs | IntoExpr | Iterable[IntoExpr] | None | Column or expression inputs used by the operation; strings are parsed as column names and other non-expression values as literals. |
more_exprs | IntoExpr | Additional column or expression inputs supplied positionally. |
Expr
import polars as pl
df = pl.DataFrame({"a": [True, False, True], "b": [False, False, False]})
result = df.select(pl.all().sum())
print(result)Selects every column and computes each column's sum.
Apply the same expression to every column in a DataFrame selection.
Aggregate selected columns independently, such as summing each column.
Build expressions from named columns and literal inputs.
With no arguments, pl.all() is an alias for pl.col("*"). It produces an expression that selects every column, allowing operations such as sum() to be applied independently to each selected column.
Follow-up: How would you express a horizontal Boolean AND? Use pl.all_horizontal rather than relying on the deprecated horizontal behavior of pl.all.
The function accepts expression inputs and additional positional expressions. Strings are interpreted as column names, while other non-expression values are interpreted as literals.
Follow-up: What happens with exactly one string argument? It aliases pl.col(name).any(), so it is not equivalent to selecting all columns.
pl.all can compute a bitwise AND horizontally across multiple columns, but the documentation marks this behavior as deprecated. New code should use pl.all_horizontal for that operation.
Follow-up: What remains the main selector use of pl.all()? Calling it without arguments to target every column for subsequent expression operations.
polars.all_horizontalpolars.colpolars.excludepolars.Expr.all