Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Polars · Function

pl.all

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.

How it works

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.

Syntax

polars.all(*exprs: IntoExpr | Iterable[IntoExpr] | None = None, **more_exprs: IntoExpr) -> Expr

Parameters

NameTypeDescription
exprsIntoExpr | Iterable[IntoExpr] | NoneColumn or expression inputs used by the operation; strings are parsed as column names and other non-expression values as literals.
more_exprsIntoExprAdditional column or expression inputs supplied positionally.

Returns

Expr

Key points

  • Calling pl.all() with no arguments selects every column.
  • The selected columns can be used as inputs to an aggregation expression.
  • Expression objects are valid inputs.
  • String arguments identify columns; other non-expression values become literals.
  • Further input columns can be supplied through additional positional arguments.

Common mistakes

  • Do not use pl.all for horizontal bitwise AND across multiple columns in new code; use pl.all_horizontal instead.
  • A single string is treated as one column's any aggregation rather than as a general all-columns selector.

Example: Select all columns

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.

When to use it

Bulk column selection

Apply the same expression to every column in a DataFrame selection.

Per-column aggregation

Aggregate selected columns independently, such as summing each column.

Expression composition

Build expressions from named columns and literal inputs.

Interview questions

QWhat does pl.all() return when called without arguments?

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.

QWhat kinds of arguments can pl.all accept?

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.

QWhich use of pl.all is deprecated?

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_horizontal
  • polars.col
  • polars.exclude
  • polars.Expr.all

Source: polars.all — Polars documentation. Checked 2026-10-15.