TableFrame API#

TableFrame#

class TableFrame(df: Mapping[str, Sequence[object] | Mapping[str, Sequence[object]]] | TdLazyFrame | None = None)#

Bases: object

Owned Functions.

cast(dtypes: Mapping[ColumnNameOrSelector | PolarsDataType, PolarsDataType] | PolarsDataType, *, strict: bool = True) TdLazyFrame[source]#

Cast columns to a new data type.

Parameters:
  • dtypes – Mapping of the column name(s) to the new data type(s).

  • strict – If True, raises an error if the cast cannot be performed.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 1    │
│ X    ┆ 10   │
│ C    ┆ 3    │
│ D    ┆ 5    │
│ M    ┆ 9    │
│ A    ┆ 100  │
│ M    ┆ 50   │
│ null ┆ 20   │
│ F    ┆ null │
└──────┴──────┘
>>>
>>> tf.cast({"b":pl.Float32}).collect()
>>>
┌──────┬───────┐
│ a    ┆ b     │
│ ---  ┆ ---   │
│ str  ┆ f32   │
╞══════╪═══════╡
│ A    ┆ 1.0   │
│ X    ┆ 10.0  │
│ C    ┆ 3.0   │
│ D    ┆ 5.0   │
│ M    ┆ 9.0   │
│ A    ┆ 100.0 │
│ M    ┆ 50.0  │
│ null ┆ 20.0  │
│ F    ┆ null  │
└──────┴───────┘
clear(n: int = 0) TdLazyFrame[source]#

Clears all rows of the TableFrame preserving the schema.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 1    │
│ X    ┆ 10   │
│ C    ┆ 3    │
│ D    ┆ 5    │
│ M    ┆ 9    │
│ A    ┆ 100  │
│ M    ┆ 50   │
│ null ┆ 20   │
│ F    ┆ null │
└──────┴──────┘
>>>
>>> tf.cast({"b":pl.Float32}).collect()
>>>
┌──────┬───────┐
│ a    ┆ b     │
│ ---  ┆ ---   │
│ str  ┆ f32   │
╞══════╪═══════╡
└──────┴───────┘
property columns: list[str]#
drop(*columns: ColumnNameOrSelector | Iterable[ColumnNameOrSelector], strict: bool = True) TdLazyFrame[source]#

Discard columns from the TableFrame.

Parameters:
  • columns – Columns to drop.

  • strict – If True, raises an error if a column does not exist.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ x    ┆ y    │
│ ---  ┆ ---  │
│ f64  ┆ f64  │
╞══════╪══════╡
│ 1.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  │
│ 10.0 ┆ 10.0 │
│ 4.0  ┆ 10.0 │
│ 5.0  ┆ null │
│ null ┆ null │
└──────┴──────┘
>>>
>>> tf.drop("y")
>>>
┌──────┐
│ x    │
│ ---  │
│ f64  │
╞══════╡
│ 1.0  │
│ 2.0  │
│ NaN  │
│ 4.0  │
│ 5.0  │
│ null │
└──────┘
drop_nans(subset: ColumnNameOrSelector | Collection[ColumnNameOrSelector] | None = None) TdLazyFrame[source]#

Drop rows with NaN values.

Parameters:

subset – Columns to look for Nan values. If None, all columns are considered.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.unique("a", keep="last")
┌─────┬─────┬──────┐
│ ss  ┆ u   ┆ ff   │
│ --- ┆ --- ┆ ---  │
│ str ┆ i64 ┆ f64  │
╞═════╪═════╪══════╡
│ A   ┆ 1   ┆ 1.1  │
│ B   ┆ 0   ┆ 0.0  │
│ A   ┆ 2   ┆ 2.2  │
│ B   ┆ 3   ┆ 3.3  │
│ B   ┆ 4   ┆ 4.4  │
│ C   ┆ 5   ┆ -1.1 │
│ C   ┆ 6   ┆ -2.2 │
│ C   ┆ 7   ┆ -3.3 │
│ D   ┆ 8   ┆ inf  │
└─────┴─────┴──────┘
>>>
drop_nulls(subset: ColumnNameOrSelector | Collection[ColumnNameOrSelector] | None = None) TdLazyFrame[source]#

Drop rows with null values.

Parameters:

subset – Columns to evaluate for null values. If None, all columns are considered.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ G    ┆ null ┆ 2.3  │
└──────┴──────┴──────┘
>>>
>>> tf.drop_nulls("a")
>>>
┌─────┬─────┬──────┐
│ ss  ┆ u   ┆ ff   │
│ --- ┆ --- ┆ ---  │
│ str ┆ i64 ┆ f64  │
╞═════╪═════╪══════╡
│ A   ┆ 1   ┆ 1.1  │
│ B   ┆ 0   ┆ 0.0  │
│ A   ┆ 2   ┆ 2.2  │
│ B   ┆ 3   ┆ 3.3  │
│ B   ┆ 4   ┆ 4.4  │
│ C   ┆ 5   ┆ -1.1 │
│ C   ┆ 6   ┆ -2.2 │
│ C   ┆ 7   ┆ -3.3 │
│ D   ┆ 8   ┆ inf  │
│ F   ┆ 9   ┆ NaN  │
└─────┴─────┴──────┘
property dtypes: list[DataType]#
classmethod empty() TdLazyFrame[source]#
explain(**kwargs)[source]#

Provide private accessibility level wrapper.

fill_nan(value: int | float | TdExpr | None) TdLazyFrame[source]#

Replace all NaN values in the TableFrame with the given value.

Parameters:

value – The value to replace NaN with.

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.fill_nan(10)
>>>
┌──────┬──────┐
│ x    ┆ y    │
│ ---  ┆ ---  │
│ f64  ┆ f64  │
╞══════╪══════╡
│ 1.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  │
│ 10.0 ┆ 10.0 │
│ 4.0  ┆ 10.0 │
│ 5.0  ┆ null │
│ null ┆ null │
└──────┴──────┘
fill_null(value: Any | TdExpr | None = None) TdLazyFrame[source]#

Replace all null values in the TableFrame with the given value.

Parameters:

value – The value to replace null with.

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.fill_null(20)
>>>
┌──────┬──────┐
│ x    ┆ y    │
│ ---  ┆ ---  │
│ f64  ┆ f64  │
╞══════╪══════╡
│ 1.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  │
│ NaN  ┆ NaN  │
│ 4.0  ┆ NaN  │
│ 5.0  ┆ 20.0 │
│ 20.0 ┆ 20.0 │
└──────┴──────┘
filter(*predicates: TdExpr | Series | str | Iterable[TdExpr | Series | str] | bool | list[bool] | ndarray[Any, Any]) TdLazyFrame[source]#

Filter the TableFrame based on the given predicates.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
│ A   ┆ 100 │
│ M   ┆ 50  │
└─────┴─────┘
>>>
>>> tf.filter(td.col("a").is_in(["A", "C"]).or_(td.col("b").eq(10)))
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ A   ┆ 100 │
└─────┴─────┘
first() TdLazyFrame[source]#

Return a TableFrame with the first row.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
>>>
>>> tf.first()
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
└─────┴─────┘
group_by(*by: td_expr.IntoTdExpr | Iterable[td_expr.IntoTdExpr]) td_group_by.TdLazyGroupBy[source]#

Perform a group by on the TableFrame.

Parameters:

by – Columns or expressions to group by.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
│ A   ┆ 100 │
│ M   ┆ 50  │
└─────┴─────┘
>>>
>>> tf.group_by(td.col("a")).agg(td.col("b").sum())
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ M   ┆ 59  │
│ A   ┆ 101 │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ X   ┆ 10  │
└─────┴─────┘
head(n: int = 5) TdLazyFrame[source]#

Return a TableFrame with the first n rows.

Parameters:

n – The number of rows to return.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
>>>
>>> tf.head(2)
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
└─────┴─────┘
inspect(**kwargs)[source]#

Provide private accessibility level wrapper.

join(other: TdLazyFrame, on: str | TdExpr | Sequence[str | TdExpr] | None = None, how: Literal['inner', 'left', 'right', 'full', 'semi', 'anti', 'cross', 'outer'] = 'inner', *, left_on: str | TdExpr | Sequence[str | TdExpr] | None = None, right_on: str | TdExpr | Sequence[str | TdExpr] | None = None, suffix: str = '_right', join_nulls: bool = False, coalesce: bool | None = None) TdLazyFrame[source]#

Join the TableFrame with another TableFrame.

Parameters:
  • other – The TableFrame to join.

  • on – Name(s) of the columns to join on. The column name(s) must be in both TableFrame’s. Don’t use this parameter if using `left_on and right_on parameters, or if how=”cross”.

  • how

    Join strategy: * inner: An inner join. * left: A left join. * right: A rigth join. * full: A full join. * cross: The cartesian product. * semi: An inner join but only returning the columns from left

    TableFrame.

    • anti: Rows from the left TableFrame that have no match

      in the right TableFrame.

  • left_on – Name(s) of the columns to join on from the left TableFrame. It must be used together wit the right_on parameter. It cannot be used with the on parameter.

  • right_on – Name(s) of the columns to join on from the right TableFrame. It must be used together wit the left_on parameter. It cannot be used with the on parameter.

  • suffix – Duplicate columns on the right Table are appended this suffix.

  • join_nulls – If null value matches should produce join rows or not.

  • coalesce – Collapse join columns into a single column.

Example:

>>> import tabsdata as td
>>>
>>> tf1: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 1    │
│ X    ┆ 10   │
│ C    ┆ 3    │
│ D    ┆ 5    │
│ M    ┆ 9    │
│ A    ┆ 100  │
│ M    ┆ 50   │
│ null ┆ 20   │
│ F    ┆ null │
└──────┴──────┘
>>>
>>> tf2: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 3    │
│ Y    ┆ 4    │
│ Z    ┆ 5    │
│ A    ┆ 0    │
│ M    ┆ 6    │
│ null ┆ 8    │
│ F    ┆ null │
└──────┴──────┘
>>>
An inner join:
>>>
>>> tf1.join(tf2, on="a", how="inner")
>>>
┌─────┬──────┬─────────┐
│ a   ┆ b    ┆ b_right │
│ --- ┆ ---  ┆ ---     │
│ str ┆ i64  ┆ i64     │
╞═════╪══════╪═════════╡
│ A   ┆ 1    ┆ 3       │
│ A   ┆ 1    ┆ 0       │
│ M   ┆ 9    ┆ 6       │
│ A   ┆ 100  ┆ 3       │
│ A   ┆ 100  ┆ 0       │
│ M   ┆ 50   ┆ 6       │
│ F   ┆ null ┆ null    │
└─────┴──────┴─────────┘
>>>
A left join:
>>>
>>> tf1.join(tf2, on="a", how="left")
>>>
┌──────┬──────┬─────────┐
│ a    ┆ b    ┆ b_right │
│ ---  ┆ ---  ┆ ---     │
│ str  ┆ i64  ┆ i64     │
╞══════╪══════╪═════════╡
│ A    ┆ 1    ┆ 3       │
│ A    ┆ 1    ┆ 0       │
│ X    ┆ 10   ┆ null    │
│ C    ┆ 3    ┆ null    │
│ D    ┆ 5    ┆ null    │
│ …    ┆ …    ┆ …       │
│ A    ┆ 100  ┆ 3       │
│ A    ┆ 100  ┆ 0       │
│ M    ┆ 50   ┆ 6       │
│ null ┆ 20   ┆ null    │
│ F    ┆ null ┆ null    │
└──────┴──────┴─────────┘
>>>
Turning off column coalesce:
>>>
>>> tf1.join(tf2, on="a", coalesce=False)
>>>
┌─────┬──────┬─────────┬─────────┐
│ a   ┆ b    ┆ a_right ┆ b_right │
│ --- ┆ ---  ┆ ---     ┆ ---     │
│ str ┆ i64  ┆ str     ┆ i64     │
╞═════╪══════╪═════════╪═════════╡
│ A   ┆ 1    ┆ A       ┆ 3       │
│ A   ┆ 1    ┆ A       ┆ 0       │
│ M   ┆ 9    ┆ M       ┆ 6       │
│ A   ┆ 100  ┆ A       ┆ 3       │
│ A   ┆ 100  ┆ A       ┆ 0       │
│ M   ┆ 50   ┆ M       ┆ 6       │
│ F   ┆ null ┆ F       ┆ null    │
└─────┴──────┴─────────┴─────────┘
last() TdLazyFrame[source]#

Return a TableFrame with the last row.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
>>>
>>> tf.last()
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ M   ┆ 9   │
└─────┴─────┘
limit(n: int = 5) TdLazyFrame[source]#

Return a TableFrame with the first n rows. This is equivalent to head.

Parameters:

n – The number of rows to return.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
>>>
>>> tf.limit(2)
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
└─────┴─────┘
property schema: Schema#
select(*exprs: td_expr.IntoTdExpr | Iterable[td_expr.IntoTdExpr], **named_exprs: td_expr.IntoTdExpr) TdLazyFrame[source]#

Select column(s) from the TableFrame.

Parameters:
  • exprs – Columns or expressions to select.

  • named_exprs – Named expressions to select.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
│ A   ┆ 100 │
│ M   ┆ 50  │
└─────┴─────┘
>>>
>>> tf.select(td.col("a"), td.col("b").mul(2).alias("bx2"),)
>>>
┌─────┬─────┐
│ a   ┆ bx2 │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 2   │
│ X   ┆ 20  │
│ C   ┆ 6   │
│ D   ┆ 10  │
│ M   ┆ 18  │
│ A   ┆ 200 │
│ M   ┆ 100 │
└─────┴─────┘
show_graph(**kwargs)[source]#

Provide private accessibility level wrapper.

slice(offset: int, length: int | None = None) TdLazyFrame[source]#

Return a TableFrame with a slice of the original TableFrame

Parameters:
  • offset – Slice starting index.

  • length – The length of the slice. None means all the way to the end.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
>>>
>>> tf.slice(2,2)
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ C   ┆ 3   │
│ D   ┆ 5   │
└─────┴─────┘
sort(by: td_expr.IntoTdExpr | Iterable[td_expr.IntoTdExpr], *more_by: td_expr.IntoTdExpr, descending: bool | Sequence[bool] = False, nulls_last: bool | Sequence[bool] = False, maintain_order: bool = False) TdLazyFrame[source]#

Sort the TableFrame by the given column(s) or expression(s).

Parameters:
  • by – Column(s) or expression(s) to sort by.

  • more_by – Additional colums to sort by.

  • descending – Specifies if the sorting should be descending or not.

  • nulls_last – Specifies if null values should be placed last.

  • maintain_order – Preserve the order of equal rows.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 1    │
│ X    ┆ 10   │
│ C    ┆ 3    │
│ D    ┆ 5    │
│ M    ┆ 9    │
│ A    ┆ 100  │
│ M    ┆ 50   │
│ null ┆ 20   │
│ F    ┆ null │
└──────┴──────┘
>>>
>>> tf.sort(td.col("a"), descending = True)
>>>
┌──────┬───────┐
│ a    ┆ b     │
│ ---  ┆ ---   │
│ str  ┆ f32   │
╞══════╪═══════╡
│ A    ┆ 1.0   │
│ X    ┆ 10.0  │
│ C    ┆ 3.0   │
│ D    ┆ 5.0   │
│ M    ┆ 9.0   │
│ A    ┆ 100.0 │
│ M    ┆ 50.0  │
│ null ┆ 20.0  │
│ F    ┆ null  │
└──────┴───────┘
tail(n: int = 5) TdLazyFrame[source]#

Return a TableFrame with the last n rows.

Parameters:

n – The number of rows to return.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ A   ┆ 1   │
│ X   ┆ 10  │
│ C   ┆ 3   │
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
>>>
>>> tf.tail(2)
>>>
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ str ┆ i64 │
╞═════╪═════╡
│ D   ┆ 5   │
│ M   ┆ 9   │
└─────┴─────┘
unique(subset: ColumnNameOrSelector | Collection[ColumnNameOrSelector] | None = None, *, keep: UniqueKeepStrategy = 'any', maintain_order: bool = False) TdLazyFrame[source]#

Deduplicate rows from the TableFrame.

Parameters:
  • subset – Columns to evaluate for duplicate values. If None, all columns are considered.

  • keep – Strategy to keep duplicates: first, last, any, none ( eliminate duplicate rows).

  • maintain_order – Preserve the order of the rows.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 1    │
│ X    ┆ 10   │
│ C    ┆ 3    │
│ D    ┆ 5    │
│ M    ┆ 9    │
│ A    ┆ 100  │
│ M    ┆ 50   │
│ null ┆ 20   │
│ F    ┆ null │
└──────┴──────┘
>>>
>>> tf.unique("a", keep="last")
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ D    ┆ 5    │
│ C    ┆ 3    │
│ X    ┆ 10   │
│ A    ┆ 100  │
│ M    ┆ 50   │
│ F    ┆ null │
│ null ┆ 20   │
└──────┴──────┘
property width: int#
with_columns(*exprs: td_expr.IntoTdExpr | Iterable[td_expr.IntoTdExpr], **named_exprs: td_expr.IntoTdExpr) TdLazyFrame[source]#

Add columns to the TableFrame.

Parameters:
  • exprs – Columns or expressions to add.

  • named_exprs – Named expressions to add.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ x    ┆ y    │
│ ---  ┆ ---  │
│ f64  ┆ f64  │
╞══════╪══════╡
│ 1.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  │
│ 10.0 ┆ 10.0 │
│ 4.0  ┆ 10.0 │
│ 5.0  ┆ null │
│ null ┆ null │
└──────┴──────┘
>>>
>>> tf.with_columns(td.col("x").mul(td.col("y")).alias("z"))
>>>
┌──────┬──────┬──────┐
│ x    ┆ y    ┆ z    │
│ ---  ┆ ---  ┆ ---  │
│ f64  ┆ f64  ┆ f64  │
╞══════╪══════╪══════╡
│ 1.0  ┆ 2.0  ┆ 2.0  │
│ 2.0  ┆ 2.0  ┆ 4.0  │
│ NaN  ┆ NaN  ┆ NaN  │
│ 4.0  ┆ NaN  ┆ NaN  │
│ 5.0  ┆ null ┆ null │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘

GroupBy#

class TdLazyGroupBy(lgb: LazyGroupBy | TdLazyGroupBy)[source]#

Bases: object

agg(*aggs: td_expr.IntoTdExpr | Iterable[td_expr.IntoTdExpr], **named_aggs: td_expr.IntoTdExpr) td_frame.TdLazyFrame[source]#

Aggregation expressions for the group by column(s).

Parameters:

*aggs – Aggregation operations.

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").sum().alias("agg")).collect()
>>>
┌──────┬─────┐
│ a    ┆ agg │
│ ---  ┆ --- │
│ str  ┆ i64 │
╞══════╪═════╡
│ A    ┆ 4   │
│ C    ┆ 5   │
│ null ┆ 6   │
│ B    ┆ 2   │
└──────┴─────┘
count() TdLazyFrame[source]#
len() TdLazyFrame[source]#

Aggregation operation that counts the rows in the group.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by(td.col("ss")).len()
>>>
┌──────┬─────┐
│ ss   ┆ len │
│ ---  ┆ --- │
│ str  ┆ u32 │
╞══════╪═════╡
│ null ┆ 1   │
│ B    ┆ 3   │
│ F    ┆ 1   │
│ C    ┆ 3   │
│ A    ┆ 2   │
│ D    ┆ 1   │
└──────┴─────┘
max() TdLazyFrame[source]#

Aggregation operation that computes the maximum value in the group for of all the non group by columns.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by("ss").max()
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ null ┆ null ┆ null │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 7    ┆ -1.1 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
└──────┴──────┴──────┘
mean() TdLazyFrame[source]#

Aggregation operation that computes the mean value in the group for of all the non group by columns.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by("ss").mean()
>>>
┌──────┬──────────┬──────────┐
│ ss   ┆ u        ┆ ff       │
│ ---  ┆ ---      ┆ ---      │
│ str  ┆ f64      ┆ f64      │
╞══════╪══════════╪══════════╡
│ null ┆ null     ┆ null     │
│ A    ┆ 1.5      ┆ 1.65     │
│ B    ┆ 2.333333 ┆ 2.566667 │
│ C    ┆ 6.0      ┆ -2.2     │
│ D    ┆ 8.0      ┆ inf      │
│ F    ┆ 9.0      ┆ NaN      │
└──────┴──────────┴──────────┘
median() TdLazyFrame[source]#

Aggregation operation that computes the median value in the group for of all the non group by columns.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by("ss").median()
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ f64  ┆ f64  │
╞══════╪══════╪══════╡
│ null ┆ null ┆ null │
│ A    ┆ 1.5  ┆ 1.65 │
│ B    ┆ 3.0  ┆ 3.3  │
│ C    ┆ 6.0  ┆ -2.2 │
│ D    ┆ 8.0  ┆ inf  │
│ F    ┆ 9.0  ┆ NaN  │
└──────┴──────┴──────┘
min() TdLazyFrame[source]#

Aggregation operation that computes the minimum value in the group for of all the non group by columns.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by("ss").min()
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ null ┆ null ┆ null │
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ C    ┆ 5    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
└──────┴──────┴──────┘
n_unique() TdLazyFrame[source]#

Aggregation operation that counts the unique values of the given column in the group for of all the non group by columns.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by("ss").n_unique()
>>>
┌──────┬─────┬─────┐
│ ss   ┆ u   ┆ ff  │
│ ---  ┆ --- ┆ --- │
│ str  ┆ u32 ┆ u32 │
╞══════╪═════╪═════╡
│ null ┆ 1   ┆ 1   │
│ A    ┆ 2   ┆ 2   │
│ B    ┆ 3   ┆ 3   │
│ C    ┆ 3   ┆ 3   │
│ D    ┆ 1   ┆ 1   │
│ F    ┆ 1   ┆ 1   │
└──────┴─────┴─────┘
sum() TdLazyFrame[source]#

Aggregation operation that computes the sum for all values in the group for of all the non group by columns.

Examples:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┬──────┐
│ ss   ┆ u    ┆ ff   │
│ ---  ┆ ---  ┆ ---  │
│ str  ┆ i64  ┆ f64  │
╞══════╪══════╪══════╡
│ A    ┆ 1    ┆ 1.1  │
│ B    ┆ 0    ┆ 0.0  │
│ A    ┆ 2    ┆ 2.2  │
│ B    ┆ 3    ┆ 3.3  │
│ B    ┆ 4    ┆ 4.4  │
│ C    ┆ 5    ┆ -1.1 │
│ C    ┆ 6    ┆ -2.2 │
│ C    ┆ 7    ┆ -3.3 │
│ D    ┆ 8    ┆ inf  │
│ F    ┆ 9    ┆ NaN  │
│ null ┆ null ┆ null │
└──────┴──────┴──────┘
>>>
>>> tf.group_by("ss").sum()
>>>
┌──────┬─────┬──────┐
│ ss   ┆ u   ┆ ff   │
│ ---  ┆ --- ┆ ---  │
│ str  ┆ i64 ┆ f64  │
╞══════╪═════╪══════╡
│ null ┆ 0   ┆ 0.0  │
│ A    ┆ 3   ┆ 3.3  │
│ B    ┆ 7   ┆ 7.7  │
│ C    ┆ 18  ┆ -6.6 │
│ D    ┆ 8   ┆ inf  │
│ F    ┆ 9   ┆ NaN  │
└──────┴─────┴──────┘

col, lit & concat#

Expressions#

class Expr(expr: Expr | TdExpr)#

Bases: object

abs() TdExpr[source]#

Return the abso lute value of the expression.

add(other: Any) TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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: PolarsDataType | type[Any], *, strict: bool = True, wrap_numerical: bool = False) TdExpr[source]#

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(pl.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() TdExpr[source]#

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() TdExpr[source]#

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: NumericLiteral | TemporalLiteral | IntoTdExprColumn | None = None, upper_bound: NumericLiteral | TemporalLiteral | IntoTdExprColumn | None = None) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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: TdExprDateTimeNameSpace#

Return an object namespace with all date-time methods for a date-time value.

eq(other: Any) TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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(value: int | float | TdExpr | None) TdExpr[source]#

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 | TdExpr | None = None, strategy: Literal['forward', 'backward', 'min', 'max', 'mean', 'zero', 'one'] | None = None, limit: int | None = None) TdExpr[source]#

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(*predicates: TdExpr | Series | str | Iterable[TdExpr | Series | str]) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

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(seed: int = 0, seed_1: int | None = None, seed_2: int | None = None, seed_3: int | None = None) TdExpr[source]#

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: IntoTdExpr, upper_bound: IntoTdExpr, closed: ClosedInterval = 'both') TdExpr[source]#

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() TdExpr[source]#

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: TdExpr | Collection[Any] | Series) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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_() TdExpr[source]#

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) TdExpr[source]#

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(exponent: TdExpr | Series | str | int | float) TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

Reinterpret the 64bit element values (i64 or u64) as a signed/unsigned integers. Only valid for 64bit integers, for other types use cast.

Parameters:

signedtrue 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) TdExpr[source]#

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) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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(offset: int | TdExpr, length: int | TdExpr | None = None) TdExpr[source]#

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() TdExpr[source]#

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: TdExprStringNameSpace#

Return an object namespace with all string methods for a string value.

sub(other: Any) TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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() TdExpr[source]#

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) TdExpr[source]#

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) TdExpr[source]#

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  │
└─────┴─────┘

String#

class TdExprStringNameSpace(expr: ExprStringNameSpace)[source]#

Bases: object

contains(pattern: str | TdExpr, *, literal: bool = False, strict: bool = True) TdExpr[source]#

Evaluate if the string contains a pattern.

Parameters:
  • pattern – The pattern to search for.

  • literal – Take the pattern as a literal string (not a regex).

  • strict – if the given pattern is not valid regex, raise an error.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.contains("ab").alias("contains"))
>>>
┌──────┬──────────┐
│ a    ┆ contains │
│ ---  ┆ ---      │
│ str  ┆ bool     │
╞══════╪══════════╡
│ a    ┆ false    │
│ ab   ┆ true     │
│ b    ┆ false    │
│ xaby ┆ true     │
│ null ┆ null     │
└──────┴──────────┘
contains_any(patterns: td_expr.IntoTdExpr, *, ascii_case_insensitive: bool = False) td_expr.TdExpr[source]#

Evaluate if the string contains any of the given patterns.

Parameters:
  • patterns – The patterns to search for.

  • ascii_case_insensitive – If true, the search is case-insensitive.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.contains_any(["a", "b"]).alias("contains_any"))
>>>
┌──────┬──────────────┐
│ a    ┆ contains_any │
│ ---  ┆ ---          │
│ str  ┆ bool         │
╞══════╪══════════════╡
│ abc  ┆ true         │
│ axy  ┆ true         │
│ xyb  ┆ true         │
│ xyz  ┆ false        │
│ null ┆ null         │
└──────┴──────────────┘
count_matches(pattern: str | TdExpr, *, literal: bool = False) TdExpr[source]#

Counts the ocurrrences of the given pattern in the string.

Parameters:
  • pattern – The pattern to extract.

  • literal – Take the pattern as a literal string (not a regex).

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.count_matches("b.").alias("count_matches"))
>>>
┌───────────┬───────────────┐
│ a         ┆ count_matches │
│ ---       ┆ ---           │
│ str       ┆ u32           │
╞═══════════╪═══════════════╡
│ a bAb c d ┆ 2             │
│ bCbb c d  ┆ 2             │
│ bb        ┆ 1             │
│ b         ┆ 0             │
│ a         ┆ 0             │
│ null      ┆ null          │
└───────────┴───────────────┘
ends_with(suffix: str | TdExpr) TdExpr[source]#

Evaluate if the string ends with.

Parameters:

suffix – The suffix to search for.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.ends_with("b").alias("ends_with"))
>>>
┌──────┬───────────┐
│ a    ┆ ends_with │
│ ---  ┆ ---       │
│ str  ┆ bool      │
╞══════╪═══════════╡
│ a    ┆ false     │
│ ab   ┆ true      │
│ b    ┆ true      │
│ xaby ┆ false     │
│ null ┆ null      │
└──────┴───────────┘
extract(pattern: TdExpr | Series | str, group_index: int = 1) TdExpr[source]#

Extract a pattern from the string.

Parameters:
  • pattern – The pattern to extract.

  • group_index – The group index to extract.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.extract("(b.b)", 1).alias("extract"))
>>>
┌───────────┬─────────┐
│ a         ┆ extract │
│ ---       ┆ ---     │
│ str       ┆ str     │
╞═══════════╪═════════╡
│ a bAb c d ┆ bAb     │
│ bCbb c d  ┆ bCb     │
│ bb        ┆ null    │
│ null      ┆ null    │
└───────────┴─────────┘
find(pattern: str | TdExpr, *, literal: bool = False, strict: bool = True) TdExpr[source]#

Find the position of the first occurrence of the given pattern.

Parameters:
  • pattern – The pattern to search for.

  • literal – Take the pattern as a literal string (not a regex).

  • strict – if the given pattern is not valid regex, raise an error.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.find("b").alias("find"))
>>>
┌──────┬──────┐
│ a    ┆ find │
│ ---  ┆ ---  │
│ str  ┆ u32  │
╞══════╪══════╡
│ a    ┆ null │
│ ab   ┆ 1    │
│ b    ┆ 0    │
│ xaby ┆ 2    │
│ null ┆ null │
└──────┴──────┘
head(n: int | TdExpr | Series | str) TdExpr[source]#

Extract the start of the string up to the given length.

Parameters:

n – The length of the head.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.head(2).alias("head"))
>>>
┌──────┬──────┐
│ a    ┆ head │
│ ---  ┆ ---  │
│ str  ┆ str  │
╞══════╪══════╡
│ abc  ┆ ab   │
│ a    ┆ a    │
│ null ┆ null │
└──────┴──────┘
len_bytes() TdExpr[source]#

Return number of bytes (not chars) of a string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.len_bytes().alias("len_bytes"))
>>>
┌──────┬────────────┐
│ a    ┆ to_decimal │
│ ---  ┆ ---        │
│ str  ┆ u32        │
╞══════╪════════════╡
│ ab   ┆ 2          │
│ 再   ┆ 3          │
│ null ┆ null       │
└──────┴────────────┘
len_chars() TdExpr[source]#

Return number of chars (not bytes) of a string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.len_chars().alias("len_chars"))
>>>
┌──────┬────────────┐
│ a    ┆ to_decimal │
│ ---  ┆ ---        │
│ str  ┆ u32        │
╞══════╪════════════╡
│ ab   ┆ 2          │
│ 再   ┆ 3          │
│ null ┆ null       │
└──────┴────────────┘
pad_end(length: int, fill_char: str = ' ') TdExpr[source]#

Pad string values at the end to the given length using the given fill character.

Parameters:
  • length – The length to end pad the string to.

  • fill_char – The character to use for padding.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.pad_end(6, "-").alias("pad_end"))
>>>
┌────────┬─────────┐
│ a      ┆ pad_end │
│ ---    ┆ ---     │
│ str    ┆ str     │
╞════════╪═════════╡
│ abc    ┆ abc---  │
│    def ┆    def  │
│ null   ┆ null    │
└────────┴─────────┘
pad_start(length: int, fill_char: str = ' ') TdExpr[source]#

Pad string values at the front to the given length using the given fill character.

Parameters:
  • length – The length to front pad the string to.

  • fill_char – The character to use for padding.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.pad_start(6, "-").alias("pad_start"))
>>>
┌────────┬───────────┐
│ a      ┆ pad_start │
│ ---    ┆ ---       │
│ str    ┆ str       │
╞════════╪═══════════╡
│ abc    ┆ ---abc    │
│    def ┆    def    │
│ null   ┆ null      │
└────────┴───────────┘
replace(pattern: str | TdExpr, value: str | TdExpr, *, literal: bool = False, n: int = 1) TdExpr[source]#

Replace the first occurence of a pattern with the given string.

Parameters:
  • pattern – The pattern to replace.

  • value – The value to replace the pattern with.

  • literal – Take the pattern as a literal string (not a regex).

  • n – Number of matches to replace.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.replace("b", "X").alias("replace"))
>>>
┌───────────┬───────────┐
│ a         ┆ replace   │
│ ---       ┆ ---       │
│ str       ┆ str       │
╞═══════════╪═══════════╡
│ a bAb c d ┆ a XAb c d │
│ bCbb c d  ┆ XCbb c d  │
│ bb        ┆ Xb        │
│ b         ┆ X         │
│ a         ┆ a         │
│ null      ┆ null      │
└───────────┴───────────┘
replace_all(pattern: str | TdExpr, value: str | TdExpr, *, literal: bool = False) TdExpr[source]#

Replace the all occurences of a pattern with the given string.

Parameters:
  • pattern – The pattern to replace.

  • value – The value to replace the pattern with.

  • literal – Take the pattern as a literal string (not a regex).

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.replace("b", "X").alias("replace"))
>>>
┌───────────┬─────────────┐
│ a         ┆ replace_all │
│ ---       ┆ ---         │
│ str       ┆ str         │
╞═══════════╪═════════════╡
│ a bAb c d ┆ a XAX c d   │
│ bCbb c d  ┆ XCXX c d    │
│ bb        ┆ XX          │
│ b         ┆ X           │
│ a         ┆ a           │
│ null      ┆ null        │
└───────────┴─────────────┘
replace_many(patterns: td_expr.IntoTdExpr | Mapping[str, str], replace_with: td_expr.IntoTdExpr | NoDefault = <no_default>, *, ascii_case_insensitive: bool = False) td_expr.TdExpr[source]#

Replace the all occurences of any the given patterns with the given string.

Parameters:
  • patterns – The patterns to replace.

  • replace_with – The value to replace the pattern with.

  • ascii_case_insensitive – If true, the search is case-insensitive.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.replace_many(["a", "b"], "X").alias("replace_many"))
>>>
┌──────┬──────────────┐
│ a    ┆ replace_many │
│ ---  ┆ ---          │
│ str  ┆ str          │
╞══════╪══════════════╡
│ abc  ┆ XXc          │
│ axy  ┆ Xxy          │
│ xyb  ┆ xyX          │
│ xyz  ┆ xyz          │
│ null ┆ null         │
└──────┴──────────────┘
reverse() TdExpr[source]#

Reverse the string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.reverse().alias("reverse"))
>>>
┌──────┬─────────┐
│ a    ┆ reverse │
│ ---  ┆ ---     │
│ str  ┆ str     │
╞══════╪═════════╡
│ abc  ┆ cba     │
│ a    ┆ a       │
│ null ┆ null    │
└──────┴─────────┘
slice(offset: int | TdExpr | Series | str, length: int | TdExpr | Series | str | None = None) TdExpr[source]#

Extract the substring at the given offset for the given length.

Parameters:
  • offset – The offset to start the slice.

  • length – The length of the slice. If None, slice until the end of the string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.slice(1,1).alias("slice"))
>>>
┌──────┬───────┐
│ a    ┆ slice │
│ ---  ┆ ---   │
│ str  ┆ str   │
╞══════╪═══════╡
│ abc  ┆ b     │
│ a    ┆       │
│ null ┆ null  │
└──────┴───────┘
starts_with(prefix: str | TdExpr) TdExpr[source]#

Evaluate if the string start with.

Parameters:

prefix – The suffix to search for.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.starts_with("a").alias("starts_with"))
>>>
┌──────┬────────────┐
│ a    ┆ start_with │
│ ---  ┆ ---        │
│ str  ┆ bool       │
╞══════╪════════════╡
│ a    ┆ true       │
│ ab   ┆ true       │
│ b    ┆ false      │
│ xaby ┆ false      │
│ null ┆ null       │
└──────┴────────────┘
strip_chars(characters: td_expr.IntoTdExpr = None) td_expr.TdExpr[source]#

Trim string values.

Parameters:

characters – Characters to trim from start and end of the string. All characteres in the given string are removed, regardless the order. Default is whitespace.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.strip_chars("a ").alias("strip_chars"))
>>>
┌─────────────────────────────────┬─────────────┐
│ a                               ┆ strip_chars │
│ ---                             ┆ ---         │
│ str                             ┆ str         │
╞═════════════════════════════════╪═════════════╡
│ acba cda                      … ┆ cba cd      │
│    xy z                         ┆ xy z        │
│ null                            ┆ null        │
└─────────────────────────────────┴─────────────┘
strip_chars_end(characters: td_expr.IntoTdExpr = None) td_expr.TdExpr[source]#

Trim string values from the end of the string.

Parameters:

characters – Characters to trim from start of the string. All ending characteres in the given string are removed, regardless the order. Default is whitespace.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.strip_chars_end("dc ").alias("strip_chars_end"))
>>>
┌───────────────────────────────┬─────────────────┐
│ a                             ┆ strip_chars_end │
│ ---                           ┆ ---             │
│ str                           ┆ str             │
╞═══════════════════════════════╪═════════════════╡
│ cba cd                        ┆ cba             │
│    xy z                       ┆    xy z         │
│ null                          ┆ null            │
└───────────────────────────────┴─────────────────┘
strip_chars_start(characters: td_expr.IntoTdExpr = None) td_expr.TdExpr[source]#

Trim string values from the start of the string.

Parameters:

characters – Characters to trim from start of the string. All starting characteres in the given string are removed, regardless the order. Default is whitespace.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.strip_chars_start("abc").alias("strip_chars_start"))
>>>
┌───────────────────────────────┬────────────────────────────┐
│ a                             ┆ strip_chars_start          │
│ ---                           ┆ ---                        │
│ str                           ┆ str                        │
╞═══════════════════════════════╪════════════════════════════╡
│ cba cd                        ┆  cd                        │
│    xy z                       ┆    xy z                    │
│ null                          ┆ null                       │
└───────────────────────────────┴────────────────────────────┘
strip_prefix(prefix: td_expr.IntoTdExpr) td_expr.TdExpr[source]#

Trim string values removing the given prefix

Parameters:

prefix – Prefix to remove from the string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.strip_prefix("cb").alias("strip_prefix"))
>>>
┌───────────────────────────────┬─────────────────┐
│ a                             ┆ strip_prefix    │
│ ---                           ┆ ---             │
│ str                           ┆ str             │
╞═══════════════════════════════╪═════════════════╡
│ cba cd                        ┆ a cd            │
│ bx                            ┆ bx              │
│ null                          ┆ null            │
└───────────────────────────────┴─────────────────┘
strip_suffix(suffix: td_expr.IntoTdExpr) td_expr.TdExpr[source]#

Trim string values removing the given suffix

Parameters:

suffix – Suffix to remove from the string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.strip_suffix("cd").alias("strip_suffix"))
>>>
┌───────────────────────────────┬─────────────────┐
│ a                             ┆ strip_suffix    │
│ ---                           ┆ ---             │
│ str                           ┆ str             │
╞═══════════════════════════════╪═════════════════╡
│ cba cd                        ┆ cba             │
│ bx                            ┆ bx              │
│ null                          ┆ null            │
└───────────────────────────────┴─────────────────┘
tail(n: int | TdExpr | Series | str) TdExpr[source]#

Extract the end of the string up to the given length.

Parameters:

n – The length of the tail.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.tail(2).alias("tail"))
>>>
┌──────┬──────┐
│ a    ┆ tail │
│ ---  ┆ ---  │
│ str  ┆ str  │
╞══════╪══════╡
│ abc  ┆ bc   │
│ a    ┆ a    │
│ null ┆ null │
└──────┴──────┘
to_date(fmt: str | None = None, *, strict: bool = True) TdExpr[source]#

Convert the string to a date.

Parameters:

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_date().alias("to_date"))
>>>
┌────────────┬────────────┐
│ a          ┆ to_date    │
│ ---        ┆ ---        │
│ str        ┆ date       │
╞════════════╪════════════╡
│ 2024-12-13 ┆ 2024-12-13 │
│ 2024-12-15 ┆ 2024-12-15 │
│ null       ┆ null       │
└────────────┴────────────┘
to_datetime(fmt: str | None = None, *, time_unit: Literal['ns', 'us', 'ms'] | None = None, time_zone: str | None = None, strict: bool = True, ambiguous: Literal['earliest', 'latest', 'raise', 'null'] | TdExpr = 'raise') TdExpr[source]#

Convert the string to a datetime.

Parameters:
  • fmt

    The datetime format string (default %Y-%m-%d %H:%M:%S)

    [formats]

    (https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html).

  • time_unit – {None, ‘us’, ‘ns’, ‘ms’} If None (default), it inferred from the format string

  • time_zone – Time zone for the resulting value.

  • strict – If the conversion fails an error will be raised.

  • ambiguous – Policy to apply on ambiguos Datetimes: ‘raise’: saises an error ‘earliest’: use the earliest datetime ‘latest’: use the latest datetime ‘null’: set to null

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_datetime().alias("to_datetime"))
>>>
┌─────────────────────┬─────────────────────┐
│ a                   ┆ to_datetime         │
│ ---                 ┆ ---                 │
│ str                 ┆ datetime[μs]        │
╞═════════════════════╪═════════════════════╡
│ 2024-12-13 08:45:34 ┆ 2024-12-13 08:45:34 │
│ 2024-12-15 18:33:00 ┆ 2024-12-15 18:33:00 │
│ null                ┆ null                │
└─────────────────────┴─────────────────────┘
to_integer(*, base: int | TdExpr | Series | str = 10, strict: bool = True) TdExpr[source]#

Covert a string to integer.

Parameters:
  • base – The base of the integer.

  • strict – If true, raise an error if the string is not a valid integer.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.to_integer(strict=False).alias("to_integer"))
>>>
┌──────┬────────────┐
│ a    ┆ to_integer │
│ ---  ┆ ---        │
│ str  ┆ i64        │
╞══════╪════════════╡
│ 1    ┆ 1          │
│ 2.2  ┆ null       │
│ a    ┆ null       │
│ null ┆ null       │
└──────┴────────────┘
to_lowercase() TdExpr[source]#

Return the lowercase of a string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_lowercase().alias("to_lowercase"))
>>>
┌──────┬───────────────┐
│ a    ┆ to_lowerrcase │
│ ---  ┆ ---           │
│ str  ┆ u32           │
╞══════╪═══════════════╡
│ aB   ┆ ab            │
│ null ┆ null          │
└──────┴───────────────┘
to_time(fmt: str | None = None, *, strict: bool = True, cache: bool = True) TdExpr[source]#

Convert the string to a time.

Parameters:

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_time().alias("to_time"))
>>>
┌─────────────────────┬─────────────────────┐
│ a                   ┆ to_datetime         │
│ ---                 ┆ ---                 │
│ str                 ┆ datetime[μs]        │
╞═════════════════════╪═════════════════════╡
│ 2024-12-13 08:45:34 ┆ 2024-12-13 08:45:34 │
│ 2024-12-15 18:33:00 ┆ 2024-12-15 18:33:00 │
│ null                ┆ null                │
└─────────────────────┴─────────────────────┘
to_titlecase() TdExpr[source]#

Uppercase the first character and lowercase all the others ones of a string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_titlecase().alias("titlecase"))
>>>
┌──────┬───────────┐
│ a    ┆ titlecase │
│ ---  ┆ ---       │
│ str  ┆ str       │
╞══════╪═══════════╡
│ ab   ┆ Ab        │
│ Ab   ┆ Ab        │
│ AB   ┆ Ab        │
│ aB   ┆ Ab        │
│ null ┆ null      │
└──────┴───────────┘
to_uppercase() TdExpr[source]#

Return the uppercase of a string.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.to_uppercase().alias("to_uppercase"))
>>>
┌──────┬──────────────┐
│ a    ┆ to_uppercase │
│ ---  ┆ ---          │
│ str  ┆ u32          │
╞══════╪══════════════╡
│ aB   ┆ AB           │
│ null ┆ null         │
└──────┴──────────────┘
zfill(length: int | TdExpr | Series | str) TdExpr[source]#

Pad numeric string values at the start to the given length using zeros.

Parameters:

length – The length to end pad the string to.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.zfill(2).alias("zfill"))
>>>
┌──────┬───────┐
│ a    ┆ zfill │
│ ---  ┆ ---   │
│ str  ┆ str   │
╞══════╪═══════╡
│ 0    ┆ 00    │
│ 1    ┆ 01    │
│ 1000 ┆ 1000  │
│ null ┆ null  │
└──────┴───────┘

Datetime#

class TdExprDateTimeNameSpace(expr: ExprDateTimeNameSpace)[source]#

Bases: object

add_business_days(n: int | td_expr.IntoTdExpr, week_mask: Iterable[bool] = (True, True, True, True, True, False, False), holidays: Iterable[dt.date] = (), roll: Roll = 'raise') td_expr.TdExpr[source]#
base_utc_offset() TdExpr[source]#
cast_time_unit(time_unit: Literal['ns', 'us', 'ms']) TdExpr[source]#
century() TdExpr[source]#
combine(time: time | TdExpr, time_unit: Literal['ns', 'us', 'ms'] = 'us') TdExpr[source]#
convert_time_zone(time_zone: str) TdExpr[source]#
date() TdExpr[source]#
datetime() TdExpr[source]#
day() TdExpr[source]#
dst_offset() TdExpr[source]#
epoch(time_unit: Literal['ns', 'us', 'ms', 's', 'd'] = 'us') TdExpr[source]#
hour() TdExpr[source]#
is_leap_year() TdExpr[source]#
iso_year() TdExpr[source]#
microsecond() TdExpr[source]#
millennium() TdExpr[source]#
millisecond() TdExpr[source]#
minute() TdExpr[source]#
month() TdExpr[source]#
month_end() TdExpr[source]#
month_start() TdExpr[source]#
nanosecond() TdExpr[source]#
offset_by(by: str | TdExpr) TdExpr[source]#
ordinal_day() TdExpr[source]#
quarter() TdExpr[source]#
replace(*, year: int | td_expr.IntoTdExpr | None = None, month: int | td_expr.IntoTdExpr | None = None, day: int | td_expr.IntoTdExpr | None = None, hour: int | td_expr.IntoTdExpr | None = None, minute: int | td_expr.IntoTdExpr | None = None, second: int | td_expr.IntoTdExpr | None = None, microsecond: int | td_expr.IntoTdExpr | None = None, ambiguous: Ambiguous | td_expr.TdExpr = 'raise') td_expr.TdExpr[source]#
replace_time_zone(time_zone: str | None, *, ambiguous: Literal['earliest', 'latest', 'raise', 'null'] | TdExpr = 'raise', non_existent: Literal['raise', 'null'] = 'raise') TdExpr[source]#
second(*, fractional: bool = False) TdExpr[source]#
strftime(fmt: str) TdExpr[source]#
time() TdExpr[source]#
timestamp(time_unit: Literal['ns', 'us', 'ms'] = 'us') TdExpr[source]#
to_string(fmt: str | None = None) TdExpr[source]#
total_days() TdExpr[source]#
total_hours() TdExpr[source]#
total_microseconds() TdExpr[source]#
total_milliseconds() TdExpr[source]#
total_minutes() TdExpr[source]#
total_nanoseconds() TdExpr[source]#
total_seconds() TdExpr[source]#
truncate(every: str | timedelta | TdExpr) TdExpr[source]#
week() TdExpr[source]#
weekday() TdExpr[source]#
with_time_unit(time_unit: Literal['ns', 'us', 'ms']) TdExpr[source]#
year() TdExpr[source]#