Math#

Function

Description

ABS

Returns the absolute value of the input column.

CBRT

Returns the cube root (βˆ›) of a number.

CEIL

Returns the nearest integer closest from zero.

EXP

Computes the exponential of the given value.

FLOOR

Returns the nearest integer away from zero.

LN

Computes the natural logarithm of the given value.

LOG

Computes the base logarithm of the given value.

LOG2

Computes the logarithm of the given value in base 2.

LOG10

Computes the logarithm of the given value in base 10.

LOG1P

Computes the natural logarithm of β€œgiven value plus one”.

MOD

Returns the remainder of a numeric expression divided by another numeric expression.

PI

Returns a (very good) approximation of πœ‹.

POW

Returns the value to the power of the given exponent.

ROUND

Round a number to x decimals (default: 0) away from zero.

SIGN

Returns the sign of the argument as -1, 0, or +1.

SQRT

Returns the square root (√) of a number.

ABS#

Returns the absolute value of the input column.

Example:

df = pl.DataFrame({"a": [-1.0, 0.0, 1.0, -2.0]})
df.sql("""
  SELECT ABS(a) FROM self
""")
# shape: (4, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ a   β”‚
# β”‚ --- β”‚
# β”‚ f64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 1.0 β”‚
# β”‚ 0.0 β”‚
# β”‚ 1.0 β”‚
# β”‚ 2.0 β”‚
# β””β”€β”€β”€β”€β”€β”˜

CBRT#

Returns the cube root (βˆ›) of a number.

Example:

df = pl.DataFrame({"a": [1.0, 2.0, 4.0]})
df.sql("""
  SELECT CBRT(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ a        β”‚
# β”‚ ---      β”‚
# β”‚ f64      β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•β•‘
# β”‚ 1.0      β”‚
# β”‚ 1.259921 β”‚
# β”‚ 1.587401 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CEIL#

Returns the nearest integer closest from zero.

Example:

df = pl.DataFrame({"a": [0.1, 2.8, 4.30]})
df.sql("""
  SELECT CEIL(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ a   β”‚
# β”‚ --- β”‚
# β”‚ f64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 1.0 β”‚
# β”‚ 3.0 β”‚
# β”‚ 5.0 β”‚
# β””β”€β”€β”€β”€β”€β”˜

EXP#

Computes the exponential of the given value.

Example:

df = pl.DataFrame({"a": [1, 2, 4]})
df.sql("""
  SELECT EXP(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ a        β”‚
# β”‚ ---      β”‚
# β”‚ f64      β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•β•‘
# β”‚ 2.718282 β”‚
# β”‚ 7.389056 β”‚
# β”‚ 54.59815 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

FLOOR#

Returns the nearest integer away from zero.

Example:

df = pl.DataFrame({"a": [0.1, 2.8, 4.30]})
df.sql("""
  SELECT FLOOR(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ a   β”‚
# β”‚ --- β”‚
# β”‚ f64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 0.0 β”‚
# β”‚ 2.0 β”‚
# β”‚ 4.0 β”‚
# β””β”€β”€β”€β”€β”€β”˜

LN#

Computes the natural logarithm of the given value.

Example:

df = pl.DataFrame({"a": [1, 2, 4]})
df.sql("""
  SELECT LN(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ a        β”‚
# β”‚ ---      β”‚
# β”‚ f64      β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•β•‘
# β”‚ 0.0      β”‚
# β”‚ 0.693147 β”‚
# β”‚ 1.386294 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

LOG#

Computes the base logarithm of the given value.

Example:

df = pl.DataFrame({"a": [1, 2, 4]})
df.sql("""
  SELECT LOG(a, 10) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ a       β”‚
# β”‚ ---     β”‚
# β”‚ f64     β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•‘
# β”‚ 0.0     β”‚
# β”‚ 0.30103 β”‚
# β”‚ 0.60206 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

LOG2#

Computes the logarithm of the given value in base 2.

Example:

df = pl.DataFrame({"a": [1, 2, 4]})
df.sql("""
  SELECT LOG2(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ a   β”‚
# β”‚ --- β”‚
# β”‚ f64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 0.0 β”‚
# β”‚ 1.0 β”‚
# β”‚ 2.0 β”‚
# β””β”€β”€β”€β”€β”€β”˜

LOG10#

Computes the logarithm of the given value in base 10.

Example:

df = pl.DataFrame({"a": [1, 2, 4]})
df.sql("""
  SELECT LOG10(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ a       β”‚
# β”‚ ---     β”‚
# β”‚ f64     β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•‘
# β”‚ 0.0     β”‚
# β”‚ 0.30103 β”‚
# β”‚ 0.60206 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

LOG1P#

Computes the natural logarithm of β€œgiven value plus one”.

Example:

df = pl.DataFrame({"a": [1, 2, 4]})
df.sql("""
  SELECT LOG1P(a) FROM self
""")
# shape: (3, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ a        β”‚
# β”‚ ---      β”‚
# β”‚ f64      β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•β•‘
# β”‚ 0.693147 β”‚
# β”‚ 1.098612 β”‚
# β”‚ 1.609438 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

MOD#

Returns the remainder of a numeric expression divided by another numeric expression.

Example:

df = pl.DataFrame({"x": [0, 1, 2, 3, 4]})
df.sql("""
  SELECT MOD(x, 2) FROM self
""")
# shape: (5, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ x   β”‚
# β”‚ --- β”‚
# β”‚ i64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 0   β”‚
# β”‚ 1   β”‚
# β”‚ 0   β”‚
# β”‚ 1   β”‚
# β”‚ 0   β”‚
# β””β”€β”€β”€β”€β”€β”˜

PI#

Returns a (good) approximation of πœ‹.

Example:

df.sql("""
  SELECT PI() AS pi FROM self
""")
# shape: (1, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ pi       β”‚
# β”‚ ---      β”‚
# β”‚ f64      β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•β•‘
# β”‚ 3.141593 β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

POW#

Returns the value to the power of the given exponent.

Example:

df = pl.DataFrame({"x": [0, 1, 2, 3, 4]})
df.sql("""
  SELECT POW(x, 2) FROM self
""")
# shape: (5, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ x   β”‚
# β”‚ --- β”‚
# β”‚ i64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 0   β”‚
# β”‚ 1   β”‚
# β”‚ 4   β”‚
# β”‚ 9   β”‚
# β”‚ 16  β”‚
# β””β”€β”€β”€β”€β”€β”˜

ROUND#

Round a number to x decimals (default: 0) away from zero.

Example:

df = pl.DataFrame({"x": [0.4, 1.8, 2.2, 3.6, 4.1]})
df.sql("""
  SELECT ROUND(x) FROM self
""")
# shape: (5, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ x   β”‚
# β”‚ --- β”‚
# β”‚ f64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 0.0 β”‚
# β”‚ 2.0 β”‚
# β”‚ 2.0 β”‚
# β”‚ 4.0 β”‚
# β”‚ 4.0 β”‚
# β””β”€β”€β”€β”€β”€β”˜

SIGN#

Returns the sign of the argument as -1, 0, or +1.

Example:

df = pl.DataFrame({"x": [0.4, -1, 0, -2, 4]})
df.sql("""
  SELECT SIGN(x) FROM self
""")
# shape: (5, 1)
# β”Œβ”€β”€β”€β”€β”€β”
# β”‚ x   β”‚
# β”‚ --- β”‚
# β”‚ i64 β”‚
# β•žβ•β•β•β•β•β•‘
# β”‚ 1   β”‚
# β”‚ -1  β”‚
# β”‚ 0   β”‚
# β”‚ -1  β”‚
# β”‚ 1   β”‚
# β””β”€β”€β”€β”€β”€β”˜

SQRT#

Returns the square root (√) of a number.

Example:

df = pl.DataFrame({"x": [2, 4, 49, 64]})
df.sql("""
  SELECT SQRT(x) FROM self
""")
# shape: (4, 1)
# β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
# β”‚ x        β”‚
# β”‚ ---      β”‚
# β”‚ f64      β”‚
# β•žβ•β•β•β•β•β•β•β•β•β•β•‘
# β”‚ 1.414214 β”‚
# β”‚ 2.0      β”‚
# β”‚ 7.0      β”‚
# β”‚ 8.0      β”‚
# β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜