Math#
Function |
Description |
---|---|
Returns the absolute value of the input column. |
|
Returns the cube root (β) of a number. |
|
Returns the nearest integer closest from zero. |
|
Computes the exponential of the given value. |
|
Returns the nearest integer away from zero. |
|
Computes the natural logarithm of the given value. |
|
Computes the |
|
Computes the logarithm of the given value in base 2. |
|
Computes the logarithm of the given value in base 10. |
|
Computes the natural logarithm of βgiven value plus oneβ. |
|
Returns the remainder of a numeric expression divided by another numeric expression. |
|
Returns a (very good) approximation of π. |
|
Returns the value to the power of the given exponent. |
|
Round a number to |
|
Returns the sign of the argument as -1, 0, or +1. |
|
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 β
# ββββββββββββ