polars.Expr.product#

Expr.product() Expr[source]#

Compute the product of an expression.

Notes

If there are no non-null values, then the output is 1. If you would prefer empty products to return None, you can use pl.when(expr.count()>0).then(expr.product()) instead of expr.product().

Examples

>>> df = pl.DataFrame({"a": [1, 2, 3]})
>>> df.select(pl.col("a").product())
shape: (1, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 6   │
└─────┘