tabsdata.tableframe.expr.expr
- class Expr(
- expr: Expr | Expr,
Bases:
object- abs() Expr
- Categories:
numeric
Return the abso lute value of the expression.
- add(
- other: Any,
- Categories:
numeric
Equivalent to the + operator.
For numeric types adds the given input. For string types concatenates the given input.
- Parameters:
other – The value to add or concatenate.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").add(1).alias("add")) >>> ┌──────┬──────────┐ │ val ┆ add │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════════╡ │ 1 ┆ 2 │ │ 15 ┆ 16 │ │ 18 ┆ 19 │ │ 60 ┆ 61 │ │ 60 ┆ 61 │ │ 75 ┆ 76 │ │ null ┆ null │ └──────┴──────────┘
- alias(
- name: str,
- Categories:
manipulation
Set the name for a column or expression.
- Parameters:
name – Column or expression new name. The name must be a word ([A-Za-z_][A-Za-z0-9_]*) of up to 100 characters.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("age"), td.col("age").alias("Age")) >>> ┌──────┬──────┐ │ age ┆ Age │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 15 │ │ 18 ┆ 18 │ │ 60 ┆ 60 │ │ 60 ┆ 60 │ │ 75 ┆ 75 │ │ null ┆ null │ └──────┴──────┘
- and_(
- *others: Any,
- Categories:
logic
Bitwise and operator with the given expressions. It can be used with integer and bool types.
- Parameters:
others – expressions to peform the bitwise and with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("i"), td.col("i").and_(2).alias("and_")) >>> ┌──────┬──────┐ │ i ┆ and_ │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ -1 ┆ 2 │ │ 2 ┆ 2 │ │ -3 ┆ 0 │ │ 0 ┆ 0 │ │ 5 ┆ 0 │ │ 7 ┆ 2 │ │ null ┆ null │ └──────┴──────┘
- arccos() Expr
- Categories:
numeric
Calculate the inverse cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arccos().alias("arccos")) >>> ┌──────┬──────────┐ │ val ┆ arccos │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 1.560796 │ │ 0.15 ┆ 1.420228 │ │ 0.18 ┆ 1.38981 │ │ 0.6 ┆ 0.927295 │ │ 0.6 ┆ 0.927295 │ │ 0.75 ┆ 0.722734 │ │ null ┆ null │ └──────┴──────────┘
- arccosh() Expr
- Categories:
numeric
Calculate the inverse hyperbolic cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arccosh().alias("arccosh")) >>> ┌──────┬──────────┐ │ val ┆ arccosh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.1 ┆ NaN │ │ 1.5 ┆ 0.962424 │ │ 1.8 ┆ 1.192911 │ │ 6.0 ┆ 2.477889 │ │ 6.0 ┆ 2.477889 │ │ 7.5 ┆ 2.703576 │ │ null ┆ null │ └──────┴──────────┘
- arcsin() Expr
- Categories:
numeric
Calculate the inverse sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arcsin().alias("arcsin")) >>> ┌──────┬──────────┐ │ val ┆ arcsin │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 0.01 │ │ 0.15 ┆ 0.150568 │ │ 0.18 ┆ 0.180986 │ │ 0.6 ┆ 0.643501 │ │ 0.6 ┆ 0.643501 │ │ 0.75 ┆ 0.848062 │ │ null ┆ null │ └──────┴──────────┘
- arcsinh() Expr
- Categories:
numeric
Calculate the inverse hyperbolic sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arcsinh().alias("arcsinh")) >>> ┌──────┬──────────┐ │ val ┆ arcsinh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.1 ┆ 0.099834 │ │ 1.5 ┆ 1.194763 │ │ 1.8 ┆ 1.350441 │ │ 6.0 ┆ 2.49178 │ │ 6.0 ┆ 2.49178 │ │ 7.5 ┆ 2.712465 │ │ null ┆ null │ └──────┴──────────┘
- arctan() Expr
- Categories:
numeric
Calculate the inverse tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), , td.col("val").arctan().alias("arctan")) >>> ┌──────┬──────────┐ │ val ┆ arctan │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 0.01 │ │ 0.15 ┆ 0.14889 │ │ 0.18 ┆ 0.178093 │ │ 0.6 ┆ 0.54042 │ │ 0.6 ┆ 0.54042 │ │ 0.75 ┆ 0.643501 │ │ null ┆ null │ └──────┴──────────┘
- arctanh() Expr
- Categories:
numeric
Calculate the inverse hyperbolic tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), , td.col("val").arctanh().alias("arctanh")) >>> ┌──────┬──────────┐ │ val ┆ arctanh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 0.01 │ │ 0.15 ┆ 0.15114 │ │ 0.18 ┆ 0.181983 │ │ 0.6 ┆ 0.693147 │ │ 0.6 ┆ 0.693147 │ │ 0.75 ┆ 0.972955 │ │ null ┆ null │ └──────┴──────────┘
- cast(
- dtype: Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | type[Any],
- *,
- strict: bool = True,
- wrap_numerical: bool = False,
- Categories:
type_casting
Cast a value to d different type.
- Parameters:
dtype – The data type to cast to.
strict – If false, invalid casts produce null’s; if true, an excetion is raised.
wrap_numerical – If true, overflowing numbers ara handled; if false, an excetion is raised.
Example:
>>> import tabsdata as td >>> import polars as pl >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cast(td.Float64)).alias("cast") >>> ┌──────┬──────┐ │ val ┆ cast │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞══════╪══════╡ │ 1 ┆ 1.0 │ │ 15 ┆ 15.0 │ │ 18 ┆ 18.0 │ │ 60 ┆ 60.0 │ │ 60 ┆ 60.0 │ │ 75 ┆ 75.0 │ │ null ┆ null │ └──────┴──────┘
- cbrt() Expr
- Categories:
numeric
Calculate the cub root of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cbrt().alias("cbrt")) >>> ┌──────┬──────────┐ │ val ┆ cbrt │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞══════╪══════════╡ │ 1 ┆ 1.0 │ │ 15 ┆ 2.466212 │ │ 18 ┆ 2.620741 │ │ 60 ┆ 3.914868 │ │ 60 ┆ 3.914868 │ │ 75 ┆ 4.217163 │ │ null ┆ null │ └──────┴──────────┘
- ceil() Expr
- Categories:
numeric
Round up the expression to the next integer value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").first().ceil().alias("ceil")) >>> ┌──────┬─────────┐ │ temp ┆ ceil │ │ --- ┆ ------- │ │ f64 ┆ f64 │ ╞══════╪═════════╡ │ 1.0 ┆ 1.0 │ │ 1.1 ┆ 2.0 │ └──────┴─────────┘
- clip(
- lower_bound: int | float | Decimal | date | time | datetime | timedelta | Expr | Series | str | None = None,
- upper_bound: int | float | Decimal | date | time | datetime | timedelta | Expr | Series | str | None = None,
- Categories:
numeric
For element values outside the lower and upper bounds, lower values are replaced with the lower bound and upper values with the upper bound. Values within the lower and upper bounds are unaffected.
- Parameters:
lower_bound – The lower bound value. If None, the lower bound is not set.
upper_bound – The upper bound value. If None, the upper bound is
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").clip(18,65).alias("clip")) >>> ┌──────┬─────────┐ │ age ┆ clip │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═══+++═══╡ │ 1 ┆ 18 │ │ 18 ┆ 18 │ │ 50 ┆ 50 │ │ 65 ┆ 65 │ │ 70 ┆ 65 │ └──────┴─────────┘
- cos() Expr
- Categories:
numeric
Calculate the cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cos().alias("cos")) >>> ┌──────┬───────────┐ │ val ┆ cos │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════════╡ │ 0.1 ┆ 0.995004 │ │ 1.5 ┆ 0.070737 │ │ 1.8 ┆ -0.227202 │ │ 6.0 ┆ 0.96017 │ │ 6.0 ┆ 0.96017 │ │ 7.5 ┆ 0.346635 │ │ null ┆ null │ └──────┴───────────┘
- cosh() Expr
- Categories:
numeric
Calculate the hyperbolic cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cosh().alias("cosh")) >>> ┌──────┬────────────┐ │ val ┆ cosh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪════════════╡ │ 0.1 ┆ 1.005004 │ │ 1.5 ┆ 2.35241 │ │ 1.8 ┆ 3.107473 │ │ 6.0 ┆ 201.715636 │ │ 6.0 ┆ 201.715636 │ │ 7.5 ┆ 904.021484 │ │ null ┆ null │ └──────┴────────────┘
- cot() Expr
- Categories:
numeric
Calculate the cotangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cot().alias("cot")) >>> ┌──────┬───────────┐ │ val ┆ cot │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════════╡ │ 0.1 ┆ 9.966644 │ │ 1.5 ┆ 0.070915 │ │ 1.8 ┆ -0.233304 │ │ 6.0 ┆ -3.436353 │ │ 6.0 ┆ -3.436353 │ │ 7.5 ┆ 0.369547 │ │ null ┆ null │ └──────┴───────────┘
- count() Expr
- Categories:
aggregation
Aggregation operation that counts the non null values of the given column in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ a ┆ b │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 2 │ │ A ┆ 3 │ │ B ┆ 0 │ │ C ┆ 5 │ │ null ┆ 6 │ │ C ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).count().alias("count")) >>> ┌──────┬───────┐ │ a ┆ count │ │ --- ┆ --- │ │ str ┆ u32 │ ╞══════╪═══════╡ │ null ┆ 1 │ │ A ┆ 2 │ │ B ┆ 2 │ │ C ┆ 1 │ └──────┴───────┘
- degrees() Expr
- Categories:
numeric
Convert a radian value to degrees
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").degrees().alias("degrees")) >>> ┌──────┬────────────┐ │ val ┆ degress │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪════════════╡ │ 0.1 ┆ 5.729578 │ │ 1.5 ┆ 85.943669 │ │ 1.8 ┆ 103.132403 │ │ 6.0 ┆ 343.774677 │ │ 6.0 ┆ 343.774677 │ │ 7.5 ┆ 429.718346 │ │ null ┆ null │ └──────┴────────────┘
- diff(
- n: int = 1,
- Categories:
numeric
Compute the difference between an element value and the element value of the specified relative row.
It supports numberic and datetime types.
- Parameters:
n – The relative row to compute the difference with. Defaults to 1 (previous). Use a negative number to get a next row.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("i"), td.col("i").diff().diff().alias("diff")) >>> ┌──────┬──────┐ │ i ┆ diff │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ null │ │ 0 ┆ -1 │ │ 2 ┆ 2 │ │ 3 ┆ 1 │ │ 4 ┆ 1 │ │ -1 ┆ -5 │ │ -2 ┆ -1 │ │ -3 ┆ -1 │ │ -4 ┆ -1 │ │ -5 ┆ -1 │ │ null ┆ null │ └──────┴──────┘
- property dt: ExprDateTimeNameSpace
type_casting
Return an object namespace with all date-time methods for a date-time value.
- Type:
categories
- eq(
- other: Any,
- Categories:
logic
Compare if 2 expressions are equal, equivalent to expr == other. If one of the expressions is null (None) it returns null.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").eq(td.col("b")).alias("eq")) >>> ┌─────┬──────┬───────┐ │ a ┆ b ┆ eq │ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════╡ │ 1.0 ┆ 2.0 ┆ false │ │ 2.0 ┆ 2.0 ┆ true │ │ NaN ┆ NaN ┆ true │ │ 4.0 ┆ NaN ┆ false │ │ 5.0 ┆ null ┆ null │ │ null┆ null ┆ null │ └─────┴──────┴───────┘
- eq_missing(
- other: Any,
- Categories:
logic
Compare if 2 expressions are equal an, equivalent to expr == other. If one of the expressions is null (None) it returns false.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").eq(td.col("b")).alias("eq_missing")) >>> ┌─────┬──────┬───────────┐ │ a ┆ b ┆ eq_missing│ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════════╡ │ 1.0 ┆ 2.0 ┆ false │ │ 2.0 ┆ 2.0 ┆ true │ │ NaN ┆ NaN ┆ true │ │ 4.0 ┆ NaN ┆ false │ │ 5.0 ┆ null ┆ false │ │ null┆ null ┆ true │ └─────┴──────┴───────────┘
- exp() Expr
- Categories:
numeric
Calculate the exponential of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").exp().alias("exp")) >>> ┌──────┬─────────────┐ │ val ┆ exp │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═════════════╡ │ 0.1 ┆ 1.105171 │ │ 6.0 ┆ 403.428793 │ │ 6.0 ┆ 403.428793 │ │ 7.5 ┆ 1808.042414 │ │ null ┆ null │ └──────┴─────────────┘
- fill_nan( ) Expr
- Categories:
manipulation
Replace NaN values with the given value.
- Parameters:
value – The value to replace NaN values with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").fill_nan(5.5) >>> .alias("fill_nan")) >>> ┌──────┬──────────┐ │ val ┆ fill_nan │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 1.1 ┆ 1.1 │ │ 2.0 ┆ 2.0 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ 5.5 │ └──────┴──────────┘
- fill_null(
- value: Any | Expr | None = None,
- strategy: Literal['forward', 'backward', 'min', 'max', 'mean', 'zero', 'one'] | None = None,
- limit: int | None = None,
- Categories:
manipulation
Replace null values with the given value.
- Parameters:
value – The value to replace null values with.
strategy – The strategy to use for filling null values.
limit – The maximum number of null values to replace.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val") >>> .fill_null(5.5).alias("fill_null")) >>> ┌──────┬───────────┐ │ val ┆ fill_null │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════════╡ │ -1.0 ┆ -1.0 │ │ 0.0 ┆ 0.0 │ │ 1.1 ┆ 1.1 │ │ 2.0 ┆ 2.0 │ │ inf ┆ inf │ │ null ┆ 5.5 │ │ NaN ┆ NaN │ └──────┴───────────┘
- filter( ) Expr
- Categories:
filters
Apply a filter predicate to an expression.
Elements for which the predicate does not evaluate to true are discarded, evaluations to null are also discarded.
Useful in an aggregation expression.
- Parameters:
predicates – Expression(s) that evaluates to a boolean.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌───────┬─────────┐ │ state ┆ tickets │ │ --- ┆ --- │ │ str ┆ i64 │ ╞═══════╪═════════╡ │ CA ┆ 1 │ │ AL ┆ 3 │ │ CA ┆ 2 │ │ NY ┆ 2 │ │ NY ┆ 3 │ └───────┴─────────┘ >>> >>> import tabsdata as td >>> tf.group_by("state").agg(td.col("tickets") >>> .filter(td.col("tickets") !=2) >>> .sum().alias("sum_non_two")) >>> ┌───────┬─────────────┐ │ state ┆ sum_non_two │ │ --- ┆ --- │ │ str ┆ i64 │ ╞═══════╪═════════════╡ │ AL ┆ 3 │ │ NY ┆ 3 │ │ CA ┆ 1 │ └───────┴─────────────┘
- first() Expr
- Categories:
aggregation
Get the first element.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").first().alias("first")) >>> ┌──────┬─────────┐ │ age ┆ first │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═════════╡ │ 10 ┆ 10 │ │ 11 ┆ 10 │ │ 18 ┆ 10 │ │ 65 ┆ 10 │ │ 70 ┆ 10 │ └──────┴─────────┘
- floor() Expr
- Categories:
numeric
Round down the expression to the previous integer value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").ceil().alias("floor")) >>> ┌──────┬─────────┐ │ temp ┆ floor │ │ --- ┆ ------- │ │ f64 ┆ i64 │ ╞══════╪═════════╡ │ 1.0 ┆ 1 │ │ 1.1 ┆ 1 │ └──────┴─────────┘
- floordiv(
- other: Any,
Calculate the floor on the division.
- Parameters:
other – The value to divide by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").floordiv(2) >>> .alias("floordiv")) >>> ┌──────┬──────────┐ │ temp ┆ floordiv │ │ --- ┆ ------- │ │ f64 ┆ i64 │ ╞══════╪══════════╡ │ 2.5 ┆ 1 │ │ 1.4 ┆ 0 │ └──────┴──────────┘
- ge(
- other: Any,
- Categories:
logic
Greater or equal operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").ge(1.0).alias("ge")) >>> ┌──────┬─────────┐ │ temp ┆ ge │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 0.9 ┆ false │ │ 1.1 ┆ true │ └──────┴─────────┘
- gt(
- other: Any,
- Categories:
logic
Greater than operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").gt(1.0).alias("gt")) >>> ┌──────┬─────────┐ │ temp ┆ ge │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 1.0 ┆ false │ │ 1.1 ┆ true │ └──────┴─────────┘
- hash( ) Expr
- Categories:
numeric
Compute the hash of an element value.
- Parameters:
seed – The seed for the hash function.
seed_1 – The first seed for the hash function.
seed_2 – The second seed for the hash function.
seed_3 – The third seed for the hash function.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").hash(5).alias("hash")) >>> ┌──────┬─────────────────────┐ │ temp ┆ hash │ │ --- ┆ --- │ │ f64 ┆ u64 │ ╞══════╪═════════════════════╡ │ 1.1 ┆ 1438840365631752616 │ │ 2.0 ┆ 4738789230185236462 │ └──────┴─────────────────────┘
- is_between(
- lower_bound: td_typing.IntoExpr,
- upper_bound: td_typing.IntoExpr,
- closed: td_typing.ClosedInterval = 'both',
- Categories:
logic
If an expression is between the given bounds.
- Parameters:
lower_bound – The lower bound value.
upper_bound – The upper bound value.
closed – The interval type, either “both”, “left”, “right”, or “neither”
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp") >>> .is_between(0, 1).alias("between")) >>> ┌──────┬─────────┐ │ temp ┆ between │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │-1.0 ┆ false │ │ 0.0 ┆ true │ │ 0.5 ┆ true │ │ 1.0 ┆ true │ │ 1.1 ┆ false │ └──────┴─────────┘
- is_finite() Expr
- Categories:
logic
If an element value is finite.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_finite() >>> .alias("finite")) >>> ┌──────┬────────┐ │ temp ┆ finite │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪════════╡ │ 1.1 ┆ true │ │ 2.0 ┆ true │ │ inf ┆ false │ └──────┴────────┘
- is_in(
- other: Expr | Collection[Any],
- Categories:
logic
If an element value is in the given collection.
- Parameters:
other – The collection to check if the element value is in.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_in([1.1, 2.2]) >>> .alias("is_in")) >>> ┌──────┬────────┐ │ temp ┆ is_in │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪════════╡ │ 1.1 ┆ true │ │ 2.0 ┆ false │ │ inf ┆ false │ └──────┴────────┘
- is_infinite() Expr
- Categories:
logic
If an element value is infinite.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp") >>> .is_infinite().alias("infinite")) >>> ┌──────┬──────────┐ │ temp ┆ infinite │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ 2.0 ┆ false │ │ inf ┆ true │ └──────┴──────────┘
- is_nan() Expr
- Categories:
logic
If an element value is NaN.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_nan().alias("nan")) >>> ┌──────┬──────────┐ │ temp ┆ nan │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ Nan ┆ true │ │ None ┆ false │ │ inf ┆ false │ └──────┴──────────┘
- is_not_nan() Expr
- Categories:
logic
If an element value is not NaN.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_not_nan() >>> .alias("not_nan")) >>> ┌──────┬──────────┐ │ temp ┆ not_nan │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ true │ │ Nan ┆ false │ │ None ┆ false │ │ inf ┆ true │ └──────┴──────────┘
- is_not_null() Expr
- Categories:
logic
If an element value is not null (None).
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_not_null() >>> .alias("null")) >>> ┌──────┬──────────┐ │ temp ┆ not_nulL │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ true │ │ Nan ┆ true │ │ None ┆ false │ │ inf ┆ true │ └──────┴──────────┘
- is_null() Expr
- Categories:
logic
If an element value is null (None).
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_not_null() >>> .alias("null")) >>> ┌──────┬──────────┐ │ temp ┆ null │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ Nan ┆ false │ │ None ┆ true │ │ inf ┆ false │ └──────┴──────────┘
- is_unique() Expr
- Categories:
logic
If an element value is unique for all values in the column.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_unique() >>> .alias("unique")) >>> ┌──────┬──────────┐ │ temp ┆ unique │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ 1.1 ┆ false │ │ None ┆ true │ │ 2.0 ┆ true │ └──────┴──────────┘
- last() Expr
- Categories:
aggregation
Get the last element.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").first().alias("last")) >>> ┌──────┬─────────┐ │ age ┆ last │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═════════╡ │ 10 ┆ 70 │ │ 11 ┆ 70 │ │ 18 ┆ 70 │ │ 65 ┆ 70 │ │ 70 ┆ 70 │ └──────┴─────────┘
- le(
- other: Any,
- Categories:
logic
Less or equal operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").le(1.0).alias("le")) >>> ┌──────┬─────────┐ │ temp ┆ le │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 0.9 ┆ true │ │ 1.1 ┆ false │ └──────┴─────────┘
- len() Expr
- Categories:
aggregation
Aggregation operation that counts the rows in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ a ┆ b │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 2 │ │ A ┆ 3 │ │ B ┆ 0 │ │ C ┆ 5 │ │ null ┆ 6 │ │ C ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).len().alias("len")) >>> ┌──────┬─────┐ │ a ┆ len │ │ --- ┆ --- │ │ str ┆ u32 │ ╞══════╪═════╡ │ null ┆ 1 │ │ A ┆ 2 │ │ B ┆ 2 │ │ C ┆ 2 │ └──────┴─────┘
- log(
- base: float = 2.718281828459045,
- Categories:
numeric
Calculate the logarithm to the given base.
- Parameters:
base – logarithm base, defaults to e.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").log().alias("log") >>> ┌──────┬──────────┐ │ val ┆ log │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ -1.0 ┆ NaN │ │ 0.0 ┆ -inf │ │ 1.1 ┆ 0.09531 │ │ 2.0 ┆ 0.693147 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────────┘
- log10() Expr
- Categories:
numeric
Calculate the logarithm base 10.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").log10().alias("log10") >>> ┌──────┬──────────┐ │ val ┆ log10 │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ -1.0 ┆ NaN │ │ 0.0 ┆ -inf │ │ 1.1 ┆ 0.041393 │ │ 2.0 ┆ 0.30103 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────────┘
- log1p() Expr
- Categories:
numeric
Calculate the natural logarithm plus one.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").log1p().alias("log1p") >>> ┌──────┬──────────┐ │ val ┆ log1p │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ -1.0 ┆ -inf │ │ 0.0 ┆ 0.0 │ │ 1.1 ┆ 0.741937 │ │ 2.0 ┆ 1.098612 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────────┘
- lt(
- other: Any,
- Categories:
logic
Less than operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").lt(1.0).alias("lt")) >>> ┌──────┬─────────┐ │ val ┆ tl │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 1.0 ┆ false │ │ 0.1 ┆ true │ └──────┴─────────┘
- max() Expr
- Categories:
aggregation
Aggregation operation that finds the maximum value in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).max()) >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ F ┆ -5 │ │ C ┆ -1 │ │ A ┆ 2 │ │ B ┆ 4 │ │ D ┆ -4 │ │ null ┆ null │ └──────┴──────┘
- mean() Expr
- Categories:
aggregation
Aggregation operation that finds the mean of the values in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b").mean()) >>> ┌──────┬──────────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ f64 │ ╞══════╪══════════╡ │ null ┆ null │ │ A ┆ 1.5 │ │ F ┆ -5.0 │ │ C ┆ -2.0 │ │ D ┆ -4.0 │ │ B ┆ 2.333333 │ └──────┴──────────┘
- median() Expr
- Categories:
aggregation
Aggregation operation that finds the median of the values in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).median()) >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ f64 │ ╞══════╪══════╡ │ F ┆ -5.0 │ │ C ┆ -2.0 │ │ B ┆ 3.0 │ │ D ┆ -4.0 │ │ A ┆ 1.5 │ │ null ┆ null │ └──────┴──────┘
- min() Expr
- Categories:
aggregation
Aggregation operation that finds the minimum value in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).min()) >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ C ┆ -3 │ │ A ┆ 1 │ │ null ┆ null │ │ B ┆ 0 │ │ F ┆ -5 │ │ D ┆ -4 │ └──────┴──────┘
- mod(
- other: Any,
- Categories:
numeric
Modulus operator.
- Parameters:
other – The value to divide by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").mod(5).alias("mod")) >>> ┌──────┬──────┐ │ val ┆ mod │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 0 │ │ 18 ┆ 3 │ │ null ┆ null │ └──────┴──────┘
- mul(
- other: Any,
- Categories:
numeric
Multiplication operator.
- Parameters:
other – The value to multiply by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").mul(10).alias("mul")) >>> ┌──────┬──────┐ │ val ┆ mul │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 10 │ │ 15 ┆ 150 │ │ 18 ┆ 180 │ │ 75 ┆ 750 │ │ null ┆ null │ └──────┴──────┘
- n_unique() Expr
- Categories:
aggregation
Aggregation operation that counts the unique values of the given column in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).n_unique()) >>> ┌──────┬─────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ u32 │ ╞══════╪═════╡ │ D ┆ 1 │ │ C ┆ 3 │ │ A ┆ 2 │ │ B ┆ 3 │ │ F ┆ 1 │ │ null ┆ 1 │ └──────┴─────┘
- ne(
- other: Any,
- Categories:
logic
Compare if 2 expressions are not equal, equivalent to expr != other. If one of the expressions is null (None) it returns null.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").ne(td.col("b")).alias("ne")) >>> ┌─────┬──────┬───────┐ │ a ┆ b ┆ ne │ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════╡ │ 1.0 ┆ 2.0 ┆ true │ │ 2.0 ┆ 2.0 ┆ false │ │ NaN ┆ NaN ┆ false │ │ 4.0 ┆ NaN ┆ true │ │ 5.0 ┆ null ┆ null │ │ null┆ null ┆ null │ └─────┴──────┴───────┘
- ne_missing(
- other: Any,
- Categories:
logic
Compare if 2 expressions are not equal an, equivalent to expr != other. If one of the expressions is null (None) it returns false.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").eq(td.col("b")).alias("ne_missing")) >>> ┌─────┬──────┬───────────┐ │ a ┆ b ┆ ne_missing│ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════════╡ │ 1.0 ┆ 2.0 ┆ true │ │ 2.0 ┆ 2.0 ┆ false │ │ NaN ┆ NaN ┆ false │ │ 4.0 ┆ NaN ┆ true │ │ 5.0 ┆ null ┆ true │ │ null┆ null ┆ false │ └─────┴──────┴───────────┘
- neg() Expr
- Categories:
numeric
Unary minus operator.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").neg().alias("neg")) >>> ┌──────┬──────┐ │ val ┆ neg │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════╡ │ -1.0 ┆ 1.0 │ │ 0.0 ┆ -0.0 │ │ 1.1 ┆ -1.1 │ │ 2.0 ┆ -2.0 │ │ inf ┆ -inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────┘
- not_() Expr
- Categories:
logic
Negate a boolean expression.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").not_().alias("not")) >>> ┌───────┬───────┐ │ val ┆ not │ │ --- ┆ --- │ │ bool ┆ bool │ ╞═══════╪═══════╡ │ true ┆ false │ │ false ┆ true │ │ null ┆ null │ └───────┴───────┘
- or_(
- *others: Any,
- Categories:
logic
Bitwise or operator with the given expressions. It can be used with integer and bool types.
- Parameters:
others – expressions to peform the bitwise or with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").or_(1).alias("or")) >>> ┌──────┬──────┐ │ val ┆ or │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 15 │ │ 18 ┆ 19 │ │ 60 ┆ 61 │ │ null ┆ null │ └──────┴──────┘
- pow( ) Expr
- Categories:
numeric
Exponentiation operator.
- Parameters:
exponent – exponent value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").pow(2).alias("pow")) >>> ┌──────┬──────┐ │ age ┆ pow │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 225 │ │ 18 ┆ 324 │ │ 60 ┆ 3600 │ │ null ┆ null │ └──────┴──────┘
- radians() Expr
- Categories:
numeric
Convert a degree value to radians
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").radians().alias("radians")) >>> ┌─────────┬──────────┐ │ val ┆ radians │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════════╪══════════╡ │ 1 ┆ 0.017453 │ │ 15 ┆ 0.261799 │ │ 60 ┆ 1.047198 │ │ 75 ┆ 1.308997 │ │ null ┆ null │ └─────────┴──────────┘
- rank(
- method: Literal['average', 'min', 'max', 'dense', 'ordinal', 'random'] = 'average',
- *,
- descending: bool = False,
- seed: int | None = None,
- Categories:
aggregation
Compute the rank of the element values. Multiple rank types are available.
- Parameters:
method – the ranking type: ‘average’ (default), ‘dense’, ‘max’, ‘min’, ‘ordinal’ or ‘random’.
descending – if the order is ascending (default) or descending.
seed – random seed when using ‘random’ rank type.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").rank("max").alias("rank")) >>> ┌──────┬──────┐ │ val ┆ rank │ │ --- ┆ --- │ │ f64 ┆ u32 │ ╞══════╪══════╡ │ -1.0 ┆ 1 │ │ 0.0 ┆ 2 │ │ 1.1 ┆ 3 │ │ 2.0 ┆ 4 │ │ inf ┆ 5 │ │ null ┆ null │ │ NaN ┆ 6 │ └──────┴──────┘
- reinterpret(
- *,
- signed: bool = True,
- Categories:
numeric
Reinterpret the 64bit element values (i64 or u64) as a signed/unsigned integers. Only valid for 64bit integers, for other types use cast.
- Parameters:
signed – true to convert to i64, false to convert to u64. This named argument must be specified.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val") >>> .reinterpret(signed=False).alias("reinterpret")) >>> ┌──────┬─────────────┐ │ val ┆ reinterpret │ │ --- ┆ --- │ │ i64 ┆ u64 │ ╞══════╪═════════════╡ │ 3 ┆ 3 │ │ 1 ┆ 1 │ │ 5 ┆ 5 │ │ 4 ┆ 4 │ │ 2 ┆ 2 │ │ 6 ┆ 6 │ │ null ┆ null │ └──────┴─────────────┘
- round(
- decimals: int = 0,
- Categories:
numeric
Round floating point element values.
- Parameters:
decimals – number of decimal places to round to.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").round().alias("round")) >>> ┌──────┬───────┐ │ val ┆ round │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════╡ │ -1.0 ┆ -1.0 │ │ 0.0 ┆ 0.0 │ │ 1.1 ┆ 1.0 │ │ 2.0 ┆ 2.0 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴───────┘
- round_sig_figs(
- digits: int,
- Categories:
numeric
Round floating point element values to the specified significant figures.
- Parameters:
digits – number of digits to round up.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").round_sig_figs(2) >>> .alias("round_sig_figs")) >>> ┌────────┬────────────────┐ │ val ┆ round_sig_figs │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪════════════════╡ │ 0.0123 ┆ 0.012 │ │ 2.0244 ┆ 2.0 │ │ 0.0 ┆ 0.0 │ │ inf ┆ NaN │ │ 50.0 ┆ 50.0 │ │ 1.0 ┆ 1.0 │ │ NaN ┆ NaN │ │ null ┆ null │ │ 112.0 ┆ 110.0 │ │ 2142.0 ┆ 2100.0 │ └────────┴────────────────┘
- shrink_dtype() Expr
- Categories:
numeric
Cast down a column to the smallest type that can hold the element values.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").shrink_dtype() >>> .alias("shrink_dtype")) >>> ┌───────┬──────────────┐ │ val ┆ shrink_dtype │ │ --- ┆ --- │ │ i64 ┆ i32 │ ╞═══════╪══════════════╡ │ 0 ┆ 0 │ │ 256 ┆ 256 │ │ 65025 ┆ 65025 │ └───────┴──────────────┘
- sign() Expr
- Categories:
numeric
Calculate the sign of element values.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sign().alias("sign")) >>> ┌────────┬──────┐ │ val ┆ sign │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪══════╡ │ 0.0123 ┆ 1.0 │ │ 2.0244 ┆ 1.0 │ │ 0.0 ┆ 0.0 │ │ inf ┆ 1.0 │ │ -50.0 ┆ -1.0 │ │ 1.0 ┆ 1.0 │ │ NaN ┆ NaN │ │ null ┆ null │ │ -112.0 ┆ -1.0 │ │ 2142.0 ┆ 1.0 │ └────────┴──────┘
- sin() Expr
- Categories:
numeric
Calculate the sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sin().alias("sin")) >>> ┌─────┬───────────┐ │ val ┆ sin │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═══════════╡ │ 0 ┆ 0.0 │ │ 30 ┆ -0.988032 │ │ 60 ┆ -0.304811 │ │ 90 ┆ 0.893997 │ └─────┴───────────┘
- sinh() Expr
- Categories:
numeric
Calculate the hyperbolic sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sinh().alias("sinh")) >>> ┌─────┬───────────┐ │ val ┆ sinh │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═══════════╡ │ 0 ┆ 0.0 │ │ 30 ┆ 5.3432e12 │ │ 60 ┆ 5.7100e25 │ │ 90 ┆ 6.1020e38 │ └─────┴───────────┘
- slice( ) Expr
- Categories:
filters
Compute a slice of the TableFrame for the specified columns.
- Parameters:
offset – the offset to start the slice.
length – the length of the slice.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ x ┆ y │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════╡ │ 1.0 ┆ 2.0 │ │ 2.0 ┆ 2.0 │ │ NaN ┆ NaN │ │ 4.0 ┆ NaN │ │ 5.0 ┆ null │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.select(tf.all().slice(1,2)) >>> ┌─────┬─────┐ │ x ┆ y │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞═════╪═════╡ │ 2.0 ┆ 2.0 │ │ NaN ┆ NaN │ └─────┴─────┘
- sqrt() Expr
- Categories:
numeric
Calculate the square root of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sqrt().alias("sqrt")) >>> ┌──────┬──────────┐ │ val ┆ sqrt │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 1.0 ┆ 1.0 │ │ 2.0 ┆ 1.414214 │ │ NaN ┆ NaN │ │ 4.0 ┆ 2.0 │ │ 5.0 ┆ 2.236068 │ │ null ┆ null │ └──────┴──────────┘
- property str: ExprStringNameSpace
type_casting
Return an object namespace with all string methods for a string value.
- Type:
categories
- sub(
- other: Any,
- Categories:
numeric
Equivalent to the - operator.
- Parameters:
other – value to subtract.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sub(1).alias("sub")) >>> ┌──────┬──────────┐ │ val ┆ sub │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════════╡ │ 1 ┆ 0 │ │ 15 ┆ 14 │ │ 18 ┆ 17 │ │ 60 ┆ 59 │ │ 60 ┆ 59 │ │ 75 ┆ 74 │ │ null ┆ null │ └──────┴──────────┘
- sum() Expr
- Categories:
aggregation
Aggregation operation that sums the values in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).sum()) >>> ┌──────┬─────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪═════╡ │ null ┆ 0 │ │ A ┆ 3 │ │ B ┆ 7 │ │ C ┆ -6 │ │ D ┆ -4 │ │ F ┆ -5 │ └──────┴─────┘
- tan() Expr
- Categories:
numeric
Calculate the tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").tan().alias("tan")) >>> ┌─────┬───────────┐ │ val ┆ tan │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═══════════╡ │ 0 ┆ 0.0 │ │ 30 ┆ -6.405331 │ │ 60 ┆ 0.32004 │ │ 90 ┆ -1.9952 │ └─────┴───────────┘
- tanh() Expr
- Categories:
numeric
Calculate the hyperbolic tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").tanh().alias("tanh")) >>> ┌─────┬──────────┐ │ val ┆ tanh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞═════╪══════════╡ │ 0.0 ┆ 0.0 │ │ 3.0 ┆ 0.995055 │ │ 6.0 ┆ 0.999988 │ │ 9.0 ┆ 1.0 │ └─────┴──────────┘
- truediv(
- other: Any,
- Categories:
numeric
Equivalent to the float / operator.
- Parameters:
other – value to divide by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").truediv(3).alias("truediv")) >>> ┌────────┬────────────┐ │ val ┆ truediv │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪════════════╡ │ 0.0123 ┆ 0.0041 │ │ 2.0244 ┆ 0.6748 │ │ 0.0 ┆ 0.0 │ │ inf ┆ inf │ │ -50.0 ┆ -16.666667 │ │ 1.0 ┆ 0.333333 │ │ NaN ┆ NaN │ │ null ┆ null │ │ -112.0 ┆ -37.333333 │ │ 2142.0 ┆ 714.0 │ └────────┴────────────┘
- xor(
- other: Any,
- Categories:
logic
Bitwise xor operator with the given expression. It can be used with integer and bool types.
- Parameters:
other – expression to peform the bitwise xor with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").xor(8).alias("xor")) >>> ┌─────┬─────┐ │ val ┆ xor │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═════╪═════╡ │ 0 ┆ 8 │ │ 30 ┆ 22 │ │ 60 ┆ 52 │ │ 90 ┆ 82 │ └─────┴─────┘
- Expr.abs() Expr
- Categories:
numeric
Return the abso lute value of the expression.
- Expr.add(
- other: Any,
- Categories:
numeric
Equivalent to the + operator.
For numeric types adds the given input. For string types concatenates the given input.
- Parameters:
other – The value to add or concatenate.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").add(1).alias("add")) >>> ┌──────┬──────────┐ │ val ┆ add │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════════╡ │ 1 ┆ 2 │ │ 15 ┆ 16 │ │ 18 ┆ 19 │ │ 60 ┆ 61 │ │ 60 ┆ 61 │ │ 75 ┆ 76 │ │ null ┆ null │ └──────┴──────────┘
- Expr.alias(
- name: str,
- Categories:
manipulation
Set the name for a column or expression.
- Parameters:
name – Column or expression new name. The name must be a word ([A-Za-z_][A-Za-z0-9_]*) of up to 100 characters.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("age"), td.col("age").alias("Age")) >>> ┌──────┬──────┐ │ age ┆ Age │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 15 │ │ 18 ┆ 18 │ │ 60 ┆ 60 │ │ 60 ┆ 60 │ │ 75 ┆ 75 │ │ null ┆ null │ └──────┴──────┘
- Expr.and_(
- *others: Any,
- Categories:
logic
Bitwise and operator with the given expressions. It can be used with integer and bool types.
- Parameters:
others – expressions to peform the bitwise and with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("i"), td.col("i").and_(2).alias("and_")) >>> ┌──────┬──────┐ │ i ┆ and_ │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ -1 ┆ 2 │ │ 2 ┆ 2 │ │ -3 ┆ 0 │ │ 0 ┆ 0 │ │ 5 ┆ 0 │ │ 7 ┆ 2 │ │ null ┆ null │ └──────┴──────┘
- Expr.arccos() Expr
- Categories:
numeric
Calculate the inverse cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arccos().alias("arccos")) >>> ┌──────┬──────────┐ │ val ┆ arccos │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 1.560796 │ │ 0.15 ┆ 1.420228 │ │ 0.18 ┆ 1.38981 │ │ 0.6 ┆ 0.927295 │ │ 0.6 ┆ 0.927295 │ │ 0.75 ┆ 0.722734 │ │ null ┆ null │ └──────┴──────────┘
- Expr.arccosh() Expr
- Categories:
numeric
Calculate the inverse hyperbolic cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arccosh().alias("arccosh")) >>> ┌──────┬──────────┐ │ val ┆ arccosh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.1 ┆ NaN │ │ 1.5 ┆ 0.962424 │ │ 1.8 ┆ 1.192911 │ │ 6.0 ┆ 2.477889 │ │ 6.0 ┆ 2.477889 │ │ 7.5 ┆ 2.703576 │ │ null ┆ null │ └──────┴──────────┘
- Expr.arcsin() Expr
- Categories:
numeric
Calculate the inverse sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arcsin().alias("arcsin")) >>> ┌──────┬──────────┐ │ val ┆ arcsin │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 0.01 │ │ 0.15 ┆ 0.150568 │ │ 0.18 ┆ 0.180986 │ │ 0.6 ┆ 0.643501 │ │ 0.6 ┆ 0.643501 │ │ 0.75 ┆ 0.848062 │ │ null ┆ null │ └──────┴──────────┘
- Expr.arcsinh() Expr
- Categories:
numeric
Calculate the inverse hyperbolic sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").arcsinh().alias("arcsinh")) >>> ┌──────┬──────────┐ │ val ┆ arcsinh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.1 ┆ 0.099834 │ │ 1.5 ┆ 1.194763 │ │ 1.8 ┆ 1.350441 │ │ 6.0 ┆ 2.49178 │ │ 6.0 ┆ 2.49178 │ │ 7.5 ┆ 2.712465 │ │ null ┆ null │ └──────┴──────────┘
- Expr.arctan() Expr
- Categories:
numeric
Calculate the inverse tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), , td.col("val").arctan().alias("arctan")) >>> ┌──────┬──────────┐ │ val ┆ arctan │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 0.01 │ │ 0.15 ┆ 0.14889 │ │ 0.18 ┆ 0.178093 │ │ 0.6 ┆ 0.54042 │ │ 0.6 ┆ 0.54042 │ │ 0.75 ┆ 0.643501 │ │ null ┆ null │ └──────┴──────────┘
- Expr.arctanh() Expr
- Categories:
numeric
Calculate the inverse hyperbolic tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), , td.col("val").arctanh().alias("arctanh")) >>> ┌──────┬──────────┐ │ val ┆ arctanh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 0.01 ┆ 0.01 │ │ 0.15 ┆ 0.15114 │ │ 0.18 ┆ 0.181983 │ │ 0.6 ┆ 0.693147 │ │ 0.6 ┆ 0.693147 │ │ 0.75 ┆ 0.972955 │ │ null ┆ null │ └──────┴──────────┘
- Expr.cast(
- dtype: Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | type[Any],
- *,
- strict: bool = True,
- wrap_numerical: bool = False,
- Categories:
type_casting
Cast a value to d different type.
- Parameters:
dtype – The data type to cast to.
strict – If false, invalid casts produce null’s; if true, an excetion is raised.
wrap_numerical – If true, overflowing numbers ara handled; if false, an excetion is raised.
Example:
>>> import tabsdata as td >>> import polars as pl >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cast(td.Float64)).alias("cast") >>> ┌──────┬──────┐ │ val ┆ cast │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞══════╪══════╡ │ 1 ┆ 1.0 │ │ 15 ┆ 15.0 │ │ 18 ┆ 18.0 │ │ 60 ┆ 60.0 │ │ 60 ┆ 60.0 │ │ 75 ┆ 75.0 │ │ null ┆ null │ └──────┴──────┘
- Expr.cbrt() Expr
- Categories:
numeric
Calculate the cub root of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cbrt().alias("cbrt")) >>> ┌──────┬──────────┐ │ val ┆ cbrt │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞══════╪══════════╡ │ 1 ┆ 1.0 │ │ 15 ┆ 2.466212 │ │ 18 ┆ 2.620741 │ │ 60 ┆ 3.914868 │ │ 60 ┆ 3.914868 │ │ 75 ┆ 4.217163 │ │ null ┆ null │ └──────┴──────────┘
- Expr.ceil() Expr
- Categories:
numeric
Round up the expression to the next integer value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").first().ceil().alias("ceil")) >>> ┌──────┬─────────┐ │ temp ┆ ceil │ │ --- ┆ ------- │ │ f64 ┆ f64 │ ╞══════╪═════════╡ │ 1.0 ┆ 1.0 │ │ 1.1 ┆ 2.0 │ └──────┴─────────┘
- Expr.clip(
- lower_bound: int | float | Decimal | date | time | datetime | timedelta | Expr | Series | str | None = None,
- upper_bound: int | float | Decimal | date | time | datetime | timedelta | Expr | Series | str | None = None,
- Categories:
numeric
For element values outside the lower and upper bounds, lower values are replaced with the lower bound and upper values with the upper bound. Values within the lower and upper bounds are unaffected.
- Parameters:
lower_bound – The lower bound value. If None, the lower bound is not set.
upper_bound – The upper bound value. If None, the upper bound is
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").clip(18,65).alias("clip")) >>> ┌──────┬─────────┐ │ age ┆ clip │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═══+++═══╡ │ 1 ┆ 18 │ │ 18 ┆ 18 │ │ 50 ┆ 50 │ │ 65 ┆ 65 │ │ 70 ┆ 65 │ └──────┴─────────┘
- Expr.cos() Expr
- Categories:
numeric
Calculate the cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cos().alias("cos")) >>> ┌──────┬───────────┐ │ val ┆ cos │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════════╡ │ 0.1 ┆ 0.995004 │ │ 1.5 ┆ 0.070737 │ │ 1.8 ┆ -0.227202 │ │ 6.0 ┆ 0.96017 │ │ 6.0 ┆ 0.96017 │ │ 7.5 ┆ 0.346635 │ │ null ┆ null │ └──────┴───────────┘
- Expr.cosh() Expr
- Categories:
numeric
Calculate the hyperbolic cosine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cosh().alias("cosh")) >>> ┌──────┬────────────┐ │ val ┆ cosh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪════════════╡ │ 0.1 ┆ 1.005004 │ │ 1.5 ┆ 2.35241 │ │ 1.8 ┆ 3.107473 │ │ 6.0 ┆ 201.715636 │ │ 6.0 ┆ 201.715636 │ │ 7.5 ┆ 904.021484 │ │ null ┆ null │ └──────┴────────────┘
- Expr.cot() Expr
- Categories:
numeric
Calculate the cotangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").cot().alias("cot")) >>> ┌──────┬───────────┐ │ val ┆ cot │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════════╡ │ 0.1 ┆ 9.966644 │ │ 1.5 ┆ 0.070915 │ │ 1.8 ┆ -0.233304 │ │ 6.0 ┆ -3.436353 │ │ 6.0 ┆ -3.436353 │ │ 7.5 ┆ 0.369547 │ │ null ┆ null │ └──────┴───────────┘
- Expr.count() Expr
- Categories:
aggregation
Aggregation operation that counts the non null values of the given column in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ a ┆ b │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 2 │ │ A ┆ 3 │ │ B ┆ 0 │ │ C ┆ 5 │ │ null ┆ 6 │ │ C ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).count().alias("count")) >>> ┌──────┬───────┐ │ a ┆ count │ │ --- ┆ --- │ │ str ┆ u32 │ ╞══════╪═══════╡ │ null ┆ 1 │ │ A ┆ 2 │ │ B ┆ 2 │ │ C ┆ 1 │ └──────┴───────┘
- Expr.degrees() Expr
- Categories:
numeric
Convert a radian value to degrees
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").degrees().alias("degrees")) >>> ┌──────┬────────────┐ │ val ┆ degress │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪════════════╡ │ 0.1 ┆ 5.729578 │ │ 1.5 ┆ 85.943669 │ │ 1.8 ┆ 103.132403 │ │ 6.0 ┆ 343.774677 │ │ 6.0 ┆ 343.774677 │ │ 7.5 ┆ 429.718346 │ │ null ┆ null │ └──────┴────────────┘
- Expr.diff(
- n: int = 1,
- Categories:
numeric
Compute the difference between an element value and the element value of the specified relative row.
It supports numberic and datetime types.
- Parameters:
n – The relative row to compute the difference with. Defaults to 1 (previous). Use a negative number to get a next row.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("i"), td.col("i").diff().diff().alias("diff")) >>> ┌──────┬──────┐ │ i ┆ diff │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ null │ │ 0 ┆ -1 │ │ 2 ┆ 2 │ │ 3 ┆ 1 │ │ 4 ┆ 1 │ │ -1 ┆ -5 │ │ -2 ┆ -1 │ │ -3 ┆ -1 │ │ -4 ┆ -1 │ │ -5 ┆ -1 │ │ null ┆ null │ └──────┴──────┘
- Expr.eq(
- other: Any,
- Categories:
logic
Compare if 2 expressions are equal, equivalent to expr == other. If one of the expressions is null (None) it returns null.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").eq(td.col("b")).alias("eq")) >>> ┌─────┬──────┬───────┐ │ a ┆ b ┆ eq │ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════╡ │ 1.0 ┆ 2.0 ┆ false │ │ 2.0 ┆ 2.0 ┆ true │ │ NaN ┆ NaN ┆ true │ │ 4.0 ┆ NaN ┆ false │ │ 5.0 ┆ null ┆ null │ │ null┆ null ┆ null │ └─────┴──────┴───────┘
- Expr.eq_missing(
- other: Any,
- Categories:
logic
Compare if 2 expressions are equal an, equivalent to expr == other. If one of the expressions is null (None) it returns false.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").eq(td.col("b")).alias("eq_missing")) >>> ┌─────┬──────┬───────────┐ │ a ┆ b ┆ eq_missing│ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════════╡ │ 1.0 ┆ 2.0 ┆ false │ │ 2.0 ┆ 2.0 ┆ true │ │ NaN ┆ NaN ┆ true │ │ 4.0 ┆ NaN ┆ false │ │ 5.0 ┆ null ┆ false │ │ null┆ null ┆ true │ └─────┴──────┴───────────┘
- Expr.exp() Expr
- Categories:
numeric
Calculate the exponential of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").exp().alias("exp")) >>> ┌──────┬─────────────┐ │ val ┆ exp │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═════════════╡ │ 0.1 ┆ 1.105171 │ │ 6.0 ┆ 403.428793 │ │ 6.0 ┆ 403.428793 │ │ 7.5 ┆ 1808.042414 │ │ null ┆ null │ └──────┴─────────────┘
- Expr.fill_nan( ) Expr
- Categories:
manipulation
Replace NaN values with the given value.
- Parameters:
value – The value to replace NaN values with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").fill_nan(5.5) >>> .alias("fill_nan")) >>> ┌──────┬──────────┐ │ val ┆ fill_nan │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 1.1 ┆ 1.1 │ │ 2.0 ┆ 2.0 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ 5.5 │ └──────┴──────────┘
- Expr.fill_null(
- value: Any | Expr | None = None,
- strategy: Literal['forward', 'backward', 'min', 'max', 'mean', 'zero', 'one'] | None = None,
- limit: int | None = None,
- Categories:
manipulation
Replace null values with the given value.
- Parameters:
value – The value to replace null values with.
strategy – The strategy to use for filling null values.
limit – The maximum number of null values to replace.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val") >>> .fill_null(5.5).alias("fill_null")) >>> ┌──────┬───────────┐ │ val ┆ fill_null │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════════╡ │ -1.0 ┆ -1.0 │ │ 0.0 ┆ 0.0 │ │ 1.1 ┆ 1.1 │ │ 2.0 ┆ 2.0 │ │ inf ┆ inf │ │ null ┆ 5.5 │ │ NaN ┆ NaN │ └──────┴───────────┘
- Expr.filter( ) Expr
- Categories:
filters
Apply a filter predicate to an expression.
Elements for which the predicate does not evaluate to true are discarded, evaluations to null are also discarded.
Useful in an aggregation expression.
- Parameters:
predicates – Expression(s) that evaluates to a boolean.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌───────┬─────────┐ │ state ┆ tickets │ │ --- ┆ --- │ │ str ┆ i64 │ ╞═══════╪═════════╡ │ CA ┆ 1 │ │ AL ┆ 3 │ │ CA ┆ 2 │ │ NY ┆ 2 │ │ NY ┆ 3 │ └───────┴─────────┘ >>> >>> import tabsdata as td >>> tf.group_by("state").agg(td.col("tickets") >>> .filter(td.col("tickets") !=2) >>> .sum().alias("sum_non_two")) >>> ┌───────┬─────────────┐ │ state ┆ sum_non_two │ │ --- ┆ --- │ │ str ┆ i64 │ ╞═══════╪═════════════╡ │ AL ┆ 3 │ │ NY ┆ 3 │ │ CA ┆ 1 │ └───────┴─────────────┘
- Expr.first() Expr
- Categories:
aggregation
Get the first element.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").first().alias("first")) >>> ┌──────┬─────────┐ │ age ┆ first │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═════════╡ │ 10 ┆ 10 │ │ 11 ┆ 10 │ │ 18 ┆ 10 │ │ 65 ┆ 10 │ │ 70 ┆ 10 │ └──────┴─────────┘
- Expr.floor() Expr
- Categories:
numeric
Round down the expression to the previous integer value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").ceil().alias("floor")) >>> ┌──────┬─────────┐ │ temp ┆ floor │ │ --- ┆ ------- │ │ f64 ┆ i64 │ ╞══════╪═════════╡ │ 1.0 ┆ 1 │ │ 1.1 ┆ 1 │ └──────┴─────────┘
- Expr.floordiv(
- other: Any,
Calculate the floor on the division.
- Parameters:
other – The value to divide by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").floordiv(2) >>> .alias("floordiv")) >>> ┌──────┬──────────┐ │ temp ┆ floordiv │ │ --- ┆ ------- │ │ f64 ┆ i64 │ ╞══════╪══════════╡ │ 2.5 ┆ 1 │ │ 1.4 ┆ 0 │ └──────┴──────────┘
- Expr.ge(
- other: Any,
- Categories:
logic
Greater or equal operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").ge(1.0).alias("ge")) >>> ┌──────┬─────────┐ │ temp ┆ ge │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 0.9 ┆ false │ │ 1.1 ┆ true │ └──────┴─────────┘
- Expr.gt(
- other: Any,
- Categories:
logic
Greater than operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").gt(1.0).alias("gt")) >>> ┌──────┬─────────┐ │ temp ┆ ge │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 1.0 ┆ false │ │ 1.1 ┆ true │ └──────┴─────────┘
- Expr.hash( ) Expr
- Categories:
numeric
Compute the hash of an element value.
- Parameters:
seed – The seed for the hash function.
seed_1 – The first seed for the hash function.
seed_2 – The second seed for the hash function.
seed_3 – The third seed for the hash function.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").hash(5).alias("hash")) >>> ┌──────┬─────────────────────┐ │ temp ┆ hash │ │ --- ┆ --- │ │ f64 ┆ u64 │ ╞══════╪═════════════════════╡ │ 1.1 ┆ 1438840365631752616 │ │ 2.0 ┆ 4738789230185236462 │ └──────┴─────────────────────┘
- Expr.is_between(
- lower_bound: td_typing.IntoExpr,
- upper_bound: td_typing.IntoExpr,
- closed: td_typing.ClosedInterval = 'both',
- Categories:
logic
If an expression is between the given bounds.
- Parameters:
lower_bound – The lower bound value.
upper_bound – The upper bound value.
closed – The interval type, either “both”, “left”, “right”, or “neither”
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp") >>> .is_between(0, 1).alias("between")) >>> ┌──────┬─────────┐ │ temp ┆ between │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │-1.0 ┆ false │ │ 0.0 ┆ true │ │ 0.5 ┆ true │ │ 1.0 ┆ true │ │ 1.1 ┆ false │ └──────┴─────────┘
- Expr.is_finite() Expr
- Categories:
logic
If an element value is finite.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_finite() >>> .alias("finite")) >>> ┌──────┬────────┐ │ temp ┆ finite │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪════════╡ │ 1.1 ┆ true │ │ 2.0 ┆ true │ │ inf ┆ false │ └──────┴────────┘
- Expr.is_in(
- other: Expr | Collection[Any],
- Categories:
logic
If an element value is in the given collection.
- Parameters:
other – The collection to check if the element value is in.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_in([1.1, 2.2]) >>> .alias("is_in")) >>> ┌──────┬────────┐ │ temp ┆ is_in │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪════════╡ │ 1.1 ┆ true │ │ 2.0 ┆ false │ │ inf ┆ false │ └──────┴────────┘
- Expr.is_infinite() Expr
- Categories:
logic
If an element value is infinite.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp") >>> .is_infinite().alias("infinite")) >>> ┌──────┬──────────┐ │ temp ┆ infinite │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ 2.0 ┆ false │ │ inf ┆ true │ └──────┴──────────┘
- Expr.is_nan() Expr
- Categories:
logic
If an element value is NaN.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_nan().alias("nan")) >>> ┌──────┬──────────┐ │ temp ┆ nan │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ Nan ┆ true │ │ None ┆ false │ │ inf ┆ false │ └──────┴──────────┘
- Expr.is_not_nan() Expr
- Categories:
logic
If an element value is not NaN.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_not_nan() >>> .alias("not_nan")) >>> ┌──────┬──────────┐ │ temp ┆ not_nan │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ true │ │ Nan ┆ false │ │ None ┆ false │ │ inf ┆ true │ └──────┴──────────┘
- Expr.is_not_null() Expr
- Categories:
logic
If an element value is not null (None).
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_not_null() >>> .alias("null")) >>> ┌──────┬──────────┐ │ temp ┆ not_nulL │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ true │ │ Nan ┆ true │ │ None ┆ false │ │ inf ┆ true │ └──────┴──────────┘
- Expr.is_null() Expr
- Categories:
logic
If an element value is null (None).
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_not_null() >>> .alias("null")) >>> ┌──────┬──────────┐ │ temp ┆ null │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ Nan ┆ false │ │ None ┆ true │ │ inf ┆ false │ └──────┴──────────┘
- Expr.is_unique() Expr
- Categories:
logic
If an element value is unique for all values in the column.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").is_unique() >>> .alias("unique")) >>> ┌──────┬──────────┐ │ temp ┆ unique │ │ --- ┆ --- │ │ f64 ┆ bool │ ╞══════╪══════════╡ │ 1.1 ┆ false │ │ 1.1 ┆ false │ │ None ┆ true │ │ 2.0 ┆ true │ └──────┴──────────┘
- Expr.last() Expr
- Categories:
aggregation
Get the last element.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").first().alias("last")) >>> ┌──────┬─────────┐ │ age ┆ last │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═════════╡ │ 10 ┆ 70 │ │ 11 ┆ 70 │ │ 18 ┆ 70 │ │ 65 ┆ 70 │ │ 70 ┆ 70 │ └──────┴─────────┘
- Expr.le(
- other: Any,
- Categories:
logic
Less or equal operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("temp"), td.col("temp").le(1.0).alias("le")) >>> ┌──────┬─────────┐ │ temp ┆ le │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 0.9 ┆ true │ │ 1.1 ┆ false │ └──────┴─────────┘
- Expr.len() Expr
- Categories:
aggregation
Aggregation operation that counts the rows in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ a ┆ b │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 2 │ │ A ┆ 3 │ │ B ┆ 0 │ │ C ┆ 5 │ │ null ┆ 6 │ │ C ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).len().alias("len")) >>> ┌──────┬─────┐ │ a ┆ len │ │ --- ┆ --- │ │ str ┆ u32 │ ╞══════╪═════╡ │ null ┆ 1 │ │ A ┆ 2 │ │ B ┆ 2 │ │ C ┆ 2 │ └──────┴─────┘
- Expr.log(
- base: float = 2.718281828459045,
- Categories:
numeric
Calculate the logarithm to the given base.
- Parameters:
base – logarithm base, defaults to e.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").log().alias("log") >>> ┌──────┬──────────┐ │ val ┆ log │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ -1.0 ┆ NaN │ │ 0.0 ┆ -inf │ │ 1.1 ┆ 0.09531 │ │ 2.0 ┆ 0.693147 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────────┘
- Expr.log10() Expr
- Categories:
numeric
Calculate the logarithm base 10.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").log10().alias("log10") >>> ┌──────┬──────────┐ │ val ┆ log10 │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ -1.0 ┆ NaN │ │ 0.0 ┆ -inf │ │ 1.1 ┆ 0.041393 │ │ 2.0 ┆ 0.30103 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────────┘
- Expr.log1p() Expr
- Categories:
numeric
Calculate the natural logarithm plus one.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").log1p().alias("log1p") >>> ┌──────┬──────────┐ │ val ┆ log1p │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ -1.0 ┆ -inf │ │ 0.0 ┆ 0.0 │ │ 1.1 ┆ 0.741937 │ │ 2.0 ┆ 1.098612 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────────┘
- Expr.lt(
- other: Any,
- Categories:
logic
Less than operator.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").lt(1.0).alias("lt")) >>> ┌──────┬─────────┐ │ val ┆ tl │ │ --- ┆ ------- │ │ f64 ┆ bool │ ╞══════╪═════════╡ │ 1.0 ┆ false │ │ 0.1 ┆ true │ └──────┴─────────┘
- Expr.max() Expr
- Categories:
aggregation
Aggregation operation that finds the maximum value in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).max()) >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ F ┆ -5 │ │ C ┆ -1 │ │ A ┆ 2 │ │ B ┆ 4 │ │ D ┆ -4 │ │ null ┆ null │ └──────┴──────┘
- Expr.mean() Expr
- Categories:
aggregation
Aggregation operation that finds the mean of the values in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b").mean()) >>> ┌──────┬──────────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ f64 │ ╞══════╪══════════╡ │ null ┆ null │ │ A ┆ 1.5 │ │ F ┆ -5.0 │ │ C ┆ -2.0 │ │ D ┆ -4.0 │ │ B ┆ 2.333333 │ └──────┴──────────┘
- Expr.median() Expr
- Categories:
aggregation
Aggregation operation that finds the median of the values in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).median()) >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ f64 │ ╞══════╪══════╡ │ F ┆ -5.0 │ │ C ┆ -2.0 │ │ B ┆ 3.0 │ │ D ┆ -4.0 │ │ A ┆ 1.5 │ │ null ┆ null │ └──────┴──────┘
- Expr.min() Expr
- Categories:
aggregation
Aggregation operation that finds the minimum value in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).min()) >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ C ┆ -3 │ │ A ┆ 1 │ │ null ┆ null │ │ B ┆ 0 │ │ F ┆ -5 │ │ D ┆ -4 │ └──────┴──────┘
- Expr.mod(
- other: Any,
- Categories:
numeric
Modulus operator.
- Parameters:
other – The value to divide by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").mod(5).alias("mod")) >>> ┌──────┬──────┐ │ val ┆ mod │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 0 │ │ 18 ┆ 3 │ │ null ┆ null │ └──────┴──────┘
- Expr.mul(
- other: Any,
- Categories:
numeric
Multiplication operator.
- Parameters:
other – The value to multiply by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").mul(10).alias("mul")) >>> ┌──────┬──────┐ │ val ┆ mul │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 10 │ │ 15 ┆ 150 │ │ 18 ┆ 180 │ │ 75 ┆ 750 │ │ null ┆ null │ └──────┴──────┘
- Expr.n_unique() Expr
- Categories:
aggregation
Aggregation operation that counts the unique values of the given column in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).n_unique()) >>> ┌──────┬─────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ u32 │ ╞══════╪═════╡ │ D ┆ 1 │ │ C ┆ 3 │ │ A ┆ 2 │ │ B ┆ 3 │ │ F ┆ 1 │ │ null ┆ 1 │ └──────┴─────┘
- Expr.ne(
- other: Any,
- Categories:
logic
Compare if 2 expressions are not equal, equivalent to expr != other. If one of the expressions is null (None) it returns null.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").ne(td.col("b")).alias("ne")) >>> ┌─────┬──────┬───────┐ │ a ┆ b ┆ ne │ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════╡ │ 1.0 ┆ 2.0 ┆ true │ │ 2.0 ┆ 2.0 ┆ false │ │ NaN ┆ NaN ┆ false │ │ 4.0 ┆ NaN ┆ true │ │ 5.0 ┆ null ┆ null │ │ null┆ null ┆ null │ └─────┴──────┴───────┘
- Expr.ne_missing(
- other: Any,
- Categories:
logic
Compare if 2 expressions are not equal an, equivalent to expr != other. If one of the expressions is null (None) it returns false.
- Parameters:
other – The value to compare with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("a").eq(td.col("b")).alias("ne_missing")) >>> ┌─────┬──────┬───────────┐ │ a ┆ b ┆ ne_missing│ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ bool │ ╞═════╪══════╪═══════════╡ │ 1.0 ┆ 2.0 ┆ true │ │ 2.0 ┆ 2.0 ┆ false │ │ NaN ┆ NaN ┆ false │ │ 4.0 ┆ NaN ┆ true │ │ 5.0 ┆ null ┆ true │ │ null┆ null ┆ false │ └─────┴──────┴───────────┘
- Expr.neg() Expr
- Categories:
numeric
Unary minus operator.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").neg().alias("neg")) >>> ┌──────┬──────┐ │ val ┆ neg │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════╡ │ -1.0 ┆ 1.0 │ │ 0.0 ┆ -0.0 │ │ 1.1 ┆ -1.1 │ │ 2.0 ┆ -2.0 │ │ inf ┆ -inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴──────┘
- Expr.not_() Expr
- Categories:
logic
Negate a boolean expression.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").not_().alias("not")) >>> ┌───────┬───────┐ │ val ┆ not │ │ --- ┆ --- │ │ bool ┆ bool │ ╞═══════╪═══════╡ │ true ┆ false │ │ false ┆ true │ │ null ┆ null │ └───────┴───────┘
- Expr.or_(
- *others: Any,
- Categories:
logic
Bitwise or operator with the given expressions. It can be used with integer and bool types.
- Parameters:
others – expressions to peform the bitwise or with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").or_(1).alias("or")) >>> ┌──────┬──────┐ │ val ┆ or │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 15 │ │ 18 ┆ 19 │ │ 60 ┆ 61 │ │ null ┆ null │ └──────┴──────┘
- Expr.pow( ) Expr
- Categories:
numeric
Exponentiation operator.
- Parameters:
exponent – exponent value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").pow(2).alias("pow")) >>> ┌──────┬──────┐ │ age ┆ pow │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 1 │ │ 15 ┆ 225 │ │ 18 ┆ 324 │ │ 60 ┆ 3600 │ │ null ┆ null │ └──────┴──────┘
- Expr.radians() Expr
- Categories:
numeric
Convert a degree value to radians
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("val"), td.col("val").radians().alias("radians")) >>> ┌─────────┬──────────┐ │ val ┆ radians │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════════╪══════════╡ │ 1 ┆ 0.017453 │ │ 15 ┆ 0.261799 │ │ 60 ┆ 1.047198 │ │ 75 ┆ 1.308997 │ │ null ┆ null │ └─────────┴──────────┘
- Expr.rank(
- method: Literal['average', 'min', 'max', 'dense', 'ordinal', 'random'] = 'average',
- *,
- descending: bool = False,
- seed: int | None = None,
- Categories:
aggregation
Compute the rank of the element values. Multiple rank types are available.
- Parameters:
method – the ranking type: ‘average’ (default), ‘dense’, ‘max’, ‘min’, ‘ordinal’ or ‘random’.
descending – if the order is ascending (default) or descending.
seed – random seed when using ‘random’ rank type.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").rank("max").alias("rank")) >>> ┌──────┬──────┐ │ val ┆ rank │ │ --- ┆ --- │ │ f64 ┆ u32 │ ╞══════╪══════╡ │ -1.0 ┆ 1 │ │ 0.0 ┆ 2 │ │ 1.1 ┆ 3 │ │ 2.0 ┆ 4 │ │ inf ┆ 5 │ │ null ┆ null │ │ NaN ┆ 6 │ └──────┴──────┘
- Expr.reinterpret(
- *,
- signed: bool = True,
- Categories:
numeric
Reinterpret the 64bit element values (i64 or u64) as a signed/unsigned integers. Only valid for 64bit integers, for other types use cast.
- Parameters:
signed – true to convert to i64, false to convert to u64. This named argument must be specified.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val") >>> .reinterpret(signed=False).alias("reinterpret")) >>> ┌──────┬─────────────┐ │ val ┆ reinterpret │ │ --- ┆ --- │ │ i64 ┆ u64 │ ╞══════╪═════════════╡ │ 3 ┆ 3 │ │ 1 ┆ 1 │ │ 5 ┆ 5 │ │ 4 ┆ 4 │ │ 2 ┆ 2 │ │ 6 ┆ 6 │ │ null ┆ null │ └──────┴─────────────┘
- Expr.round(
- decimals: int = 0,
- Categories:
numeric
Round floating point element values.
- Parameters:
decimals – number of decimal places to round to.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").round().alias("round")) >>> ┌──────┬───────┐ │ val ┆ round │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪═══════╡ │ -1.0 ┆ -1.0 │ │ 0.0 ┆ 0.0 │ │ 1.1 ┆ 1.0 │ │ 2.0 ┆ 2.0 │ │ inf ┆ inf │ │ null ┆ null │ │ NaN ┆ NaN │ └──────┴───────┘
- Expr.round_sig_figs(
- digits: int,
- Categories:
numeric
Round floating point element values to the specified significant figures.
- Parameters:
digits – number of digits to round up.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").round_sig_figs(2) >>> .alias("round_sig_figs")) >>> ┌────────┬────────────────┐ │ val ┆ round_sig_figs │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪════════════════╡ │ 0.0123 ┆ 0.012 │ │ 2.0244 ┆ 2.0 │ │ 0.0 ┆ 0.0 │ │ inf ┆ NaN │ │ 50.0 ┆ 50.0 │ │ 1.0 ┆ 1.0 │ │ NaN ┆ NaN │ │ null ┆ null │ │ 112.0 ┆ 110.0 │ │ 2142.0 ┆ 2100.0 │ └────────┴────────────────┘
- Expr.shrink_dtype() Expr
- Categories:
numeric
Cast down a column to the smallest type that can hold the element values.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").shrink_dtype() >>> .alias("shrink_dtype")) >>> ┌───────┬──────────────┐ │ val ┆ shrink_dtype │ │ --- ┆ --- │ │ i64 ┆ i32 │ ╞═══════╪══════════════╡ │ 0 ┆ 0 │ │ 256 ┆ 256 │ │ 65025 ┆ 65025 │ └───────┴──────────────┘
- Expr.sign() Expr
- Categories:
numeric
Calculate the sign of element values.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sign().alias("sign")) >>> ┌────────┬──────┐ │ val ┆ sign │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪══════╡ │ 0.0123 ┆ 1.0 │ │ 2.0244 ┆ 1.0 │ │ 0.0 ┆ 0.0 │ │ inf ┆ 1.0 │ │ -50.0 ┆ -1.0 │ │ 1.0 ┆ 1.0 │ │ NaN ┆ NaN │ │ null ┆ null │ │ -112.0 ┆ -1.0 │ │ 2142.0 ┆ 1.0 │ └────────┴──────┘
- Expr.sin() Expr
- Categories:
numeric
Calculate the sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sin().alias("sin")) >>> ┌─────┬───────────┐ │ val ┆ sin │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═══════════╡ │ 0 ┆ 0.0 │ │ 30 ┆ -0.988032 │ │ 60 ┆ -0.304811 │ │ 90 ┆ 0.893997 │ └─────┴───────────┘
- Expr.sinh() Expr
- Categories:
numeric
Calculate the hyperbolic sine of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sinh().alias("sinh")) >>> ┌─────┬───────────┐ │ val ┆ sinh │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═══════════╡ │ 0 ┆ 0.0 │ │ 30 ┆ 5.3432e12 │ │ 60 ┆ 5.7100e25 │ │ 90 ┆ 6.1020e38 │ └─────┴───────────┘
- Expr.slice( ) Expr
- Categories:
filters
Compute a slice of the TableFrame for the specified columns.
- Parameters:
offset – the offset to start the slice.
length – the length of the slice.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ x ┆ y │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════╡ │ 1.0 ┆ 2.0 │ │ 2.0 ┆ 2.0 │ │ NaN ┆ NaN │ │ 4.0 ┆ NaN │ │ 5.0 ┆ null │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.select(tf.all().slice(1,2)) >>> ┌─────┬─────┐ │ x ┆ y │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞═════╪═════╡ │ 2.0 ┆ 2.0 │ │ NaN ┆ NaN │ └─────┴─────┘
- Expr.sqrt() Expr
- Categories:
numeric
Calculate the square root of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sqrt().alias("sqrt")) >>> ┌──────┬──────────┐ │ val ┆ sqrt │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞══════╪══════════╡ │ 1.0 ┆ 1.0 │ │ 2.0 ┆ 1.414214 │ │ NaN ┆ NaN │ │ 4.0 ┆ 2.0 │ │ 5.0 ┆ 2.236068 │ │ null ┆ null │ └──────┴──────────┘
- Expr.sub(
- other: Any,
- Categories:
numeric
Equivalent to the - operator.
- Parameters:
other – value to subtract.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").sub(1).alias("sub")) >>> ┌──────┬──────────┐ │ val ┆ sub │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪══════════╡ │ 1 ┆ 0 │ │ 15 ┆ 14 │ │ 18 ┆ 17 │ │ 60 ┆ 59 │ │ 60 ┆ 59 │ │ 75 ┆ 74 │ │ null ┆ null │ └──────┴──────────┘
- Expr.sum() Expr
- Categories:
aggregation
Aggregation operation that sums the values in the group.
Examples:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> ┌──────┬──────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪══════╡ │ A ┆ 1 │ │ B ┆ 0 │ │ A ┆ 2 │ │ B ┆ 3 │ │ B ┆ 4 │ │ C ┆ -1 │ │ C ┆ -2 │ │ C ┆ -3 │ │ D ┆ -4 │ │ F ┆ -5 │ │ null ┆ null │ └──────┴──────┘ >>> >>> tf.group_by(td.col("a")).agg(td.col("b")).sum()) >>> ┌──────┬─────┐ │ ss ┆ i │ │ --- ┆ --- │ │ str ┆ i64 │ ╞══════╪═════╡ │ null ┆ 0 │ │ A ┆ 3 │ │ B ┆ 7 │ │ C ┆ -6 │ │ D ┆ -4 │ │ F ┆ -5 │ └──────┴─────┘
- Expr.tan() Expr
- Categories:
numeric
Calculate the tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").tan().alias("tan")) >>> ┌─────┬───────────┐ │ val ┆ tan │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪═══════════╡ │ 0 ┆ 0.0 │ │ 30 ┆ -6.405331 │ │ 60 ┆ 0.32004 │ │ 90 ┆ -1.9952 │ └─────┴───────────┘
- Expr.tanh() Expr
- Categories:
numeric
Calculate the hyperbolic tangent of the element value.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").tanh().alias("tanh")) >>> ┌─────┬──────────┐ │ val ┆ tanh │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞═════╪══════════╡ │ 0.0 ┆ 0.0 │ │ 3.0 ┆ 0.995055 │ │ 6.0 ┆ 0.999988 │ │ 9.0 ┆ 1.0 │ └─────┴──────────┘
- Expr.truediv(
- other: Any,
- Categories:
numeric
Equivalent to the float / operator.
- Parameters:
other – value to divide by.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").truediv(3).alias("truediv")) >>> ┌────────┬────────────┐ │ val ┆ truediv │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪════════════╡ │ 0.0123 ┆ 0.0041 │ │ 2.0244 ┆ 0.6748 │ │ 0.0 ┆ 0.0 │ │ inf ┆ inf │ │ -50.0 ┆ -16.666667 │ │ 1.0 ┆ 0.333333 │ │ NaN ┆ NaN │ │ null ┆ null │ │ -112.0 ┆ -37.333333 │ │ 2142.0 ┆ 714.0 │ └────────┴────────────┘
- Expr.xor(
- other: Any,
- Categories:
logic
Bitwise xor operator with the given expression. It can be used with integer and bool types.
- Parameters:
other – expression to peform the bitwise xor with.
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf.select(td.col("val"), td.col("val").xor(8).alias("xor")) >>> ┌─────┬─────┐ │ val ┆ xor │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═════╪═════╡ │ 0 ┆ 8 │ │ 30 ┆ 22 │ │ 60 ┆ 52 │ │ 90 ┆ 82 │ └─────┴─────┘
- P = ~P
Parameter specification variable.
The preferred way to construct a parameter specification is via the dedicated syntax for generic functions, classes, and type aliases, where the use of ‘**’ creates a parameter specification:
type IntFunc[**P] = Callable[P, int]
For compatibility with Python 3.11 and earlier, ParamSpec objects can also be created as follows:
P = ParamSpec('P')
Parameter specification variables exist primarily for the benefit of static type checkers. They are used to forward the parameter types of one callable to another callable, a pattern commonly found in higher-order functions and decorators. They are only valid when used in
Concatenate, or as the first argument toCallable, or as parameters for user-defined Generics. See class Generic for more information on generic types.An example for annotating a decorator:
def add_logging[**P, T](f: Callable[P, T]) -> Callable[P, T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner @add_logging def add_two(x: float, y: float) -> float: '''Add two numbers together.''' return x + y
Parameter specification variables can be introspected. e.g.:
>>> P = ParamSpec("P") >>> P.__name__ 'P'
Note that only parameter specification variables defined in the global scope can be pickled.
- T = ~T
Type variable.
The preferred way to construct a type variable is via the dedicated syntax for generic functions, classes, and type aliases:
class Sequence[T]: # T is a TypeVar ...
This syntax can also be used to create bound and constrained type variables:
# S is a TypeVar bound to str class StrSequence[S: str]: ... # A is a TypeVar constrained to str or bytes class StrOrBytesSequence[A: (str, bytes)]: ...
However, if desired, reusable type variables can also be constructed manually, like so:
T = TypeVar('T') # Can be anything S = TypeVar('S', bound=str) # Can be any subtype of str A = TypeVar('A', str, bytes) # Must be exactly str or bytes
Type variables exist primarily for the benefit of static type checkers. They serve as the parameters for generic types as well as for generic function and type alias definitions.
The variance of type variables is inferred by type checkers when they are created through the type parameter syntax and when
infer_variance=Trueis passed. Manually created type variables may be explicitly marked covariant or contravariant by passingcovariant=Trueorcontravariant=True. By default, manually created type variables are invariant. See PEP 484 and PEP 695 for more details.
- deprecated_category( ) type[TabsdataDeprecatedWarning]
- expr_resolves_to_multiple_outputs(
- expr: Expr,