Skip to content

Compute the logarithm of elements

Source code

Description

Compute the logarithm of elements

Usage

<Expr>$log(base = base::exp(1))

Arguments

base Numeric base value for logarithm, default is exp(1).

Value

Expr

Examples

library("polars")

pl$DataFrame(a = c(1, 2, 3, exp(1)))$
  with_columns(log = pl$col("a")$log())
#> shape: (4, 2)
#> ┌──────────┬──────────┐
#> │ a        ┆ log      │
#> │ ---      ┆ ---      │
#> │ f64      ┆ f64      │
#> ╞══════════╪══════════╡
#> │ 1.0      ┆ 0.0      │
#> │ 2.0      ┆ 0.693147 │
#> │ 3.0      ┆ 1.098612 │
#> │ 2.718282 ┆ 1.0      │
#> └──────────┴──────────┘