Skip to content

Exponentiation two expressions

Source code

Description

Method equivalent of exponentiation operator expr ^ exponent.

Usage

<Expr>$pow(exponent)

Arguments

exponent Numeric literal or expression value.

Value

Expr

See Also

  • Arithmetic operators

Examples

library("polars")

df = pl$DataFrame(x = c(1, 2, 4, 8))

df$with_columns(
  cube = pl$col("x")$pow(3),
  `x^xlog2` = pl$col("x")$pow(pl$col("x")$log(2))
)
#> shape: (4, 3)
#> ┌─────┬───────┬─────────┐
#> │ x   ┆ cube  ┆ x^xlog2 │
#> │ --- ┆ ---   ┆ ---     │
#> │ f64 ┆ f64   ┆ f64     │
#> ╞═════╪═══════╪═════════╡
#> │ 1.0 ┆ 1.0   ┆ 1.0     │
#> │ 2.0 ┆ 8.0   ┆ 2.0     │
#> │ 4.0 ┆ 64.0  ┆ 16.0    │
#> │ 8.0 ┆ 512.0 ┆ 512.0   │
#> └─────┴───────┴─────────┘