Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

polars math log for dataframe

Compute the element-wise logarithm of a column expression.

Signature

> polars math log {flags} (base)

Parameters

  • base: Logarithm base (default: e, the natural logarithm).

Input/output types:

inputoutput
polars_expressionpolars_expression
polars_selectorpolars_expression

Examples

Compute the base-2 logarithm of a column

> [[a]; [0] [1] [2] [4] [8] [16]] |
    polars into-df |
    polars select (polars col a | polars math log 2 | polars as a_base2) |
    polars collect
╭───┬─────────╮
│ # │ a_base2 │
├───┼─────────┤
│ 0 │    -inf │
│ 1 │    0.00 │
│ 2 │    1.00 │
│ 3 │    2.00 │
│ 4 │    3.00 │
│ 5 │    4.00 │
╰───┴─────────╯