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 returnNone
, you can usepl.when(expr.count()>0).then(expr.product())
instead ofexpr.product()
.Examples
>>> df = pl.DataFrame({"a": [1, 2, 3]}) >>> df.select(pl.col("a").product()) shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 6 │ └─────┘