Multiply two expressions
Description
Method equivalent of multiplication operator expr * other
.
Usage
<Expr>$mul(other)
Arguments
other
|
Numeric literal or expression value. |
Value
Expr
See Also
- Arithmetic operators
Examples
library("polars")
df = pl$DataFrame(x = c(1, 2, 4, 8, 16))
df$with_columns(
`x*2` = pl$col("x")$mul(2),
`x * xlog2` = pl$col("x")$mul(pl$col("x")$log(2))
)
#> shape: (5, 3)
#> ┌──────┬──────┬───────────┐
#> │ x ┆ x*2 ┆ x * xlog2 │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ f64 ┆ f64 │
#> ╞══════╪══════╪═══════════╡
#> │ 1.0 ┆ 2.0 ┆ 0.0 │
#> │ 2.0 ┆ 4.0 ┆ 2.0 │
#> │ 4.0 ┆ 8.0 ┆ 8.0 │
#> │ 8.0 ┆ 16.0 ┆ 24.0 │
#> │ 16.0 ┆ 32.0 ┆ 64.0 │
#> └──────┴──────┴───────────┘