Skip to main content
Version: 0.9.0

tabsdata.tableframe.expr.expr

ErrorCode
TableFrameErrorException raised when handling a (Td)TableFrame.
TdExpr
TdExpr.absReturn the abso lute value of the expression.
TdExpr.addEquivalent to the + operator.
TdExpr.aliasSet the name for a column or expression.
TdExpr.and_Bitwise and operator with the given expressions.
TdExpr.arccosCalculate the inverse cosine of the element value.
TdExpr.arccoshCalculate the inverse hyperbolic cosine of the element value.
TdExpr.arcsinCalculate the inverse sine of the element value.
TdExpr.arcsinhCalculate the inverse hyperbolic sine of the element value.
TdExpr.arctanCalculate the inverse tangent of the element value.
TdExpr.arctanhCalculate the inverse hyperbolic tangent of the element value.
TdExpr.castCast a value to d different type.
TdExpr.cbrtCalculate the cub root of the element value.
TdExpr.ceilRound up the expression to the next integer value.
TdExpr.clipFor element values outside the lower and upper bounds, lower values are replaced with the lower bound and upper values with the upper bound.
TdExpr.cosCalculate the cosine of the element value.
TdExpr.coshCalculate the hyperbolic cosine of the element value.
TdExpr.cotCalculate the cotangent of the element value.
TdExpr.countAggregation operation that counts the non null values of the given column in the group.
TdExpr.degreesConvert a radian value to degrees
TdExpr.diffCompute the difference between an element value and the element value of the specified relative row.
TdExpr.eqCompare if 2 expressions are equal, equivalent to expr == other.
TdExpr.eq_missingCompare if 2 expressions are equal an, equivalent to expr == other.
TdExpr.expCalculate the exponential of the element value.
TdExpr.fill_nanReplace NaN values with the given value.
TdExpr.fill_nullReplace null values with the given value.
TdExpr.filterApply a filter predicate to an expression.
TdExpr.firstGet the first element.
TdExpr.floorRound down the expression to the previous integer value.
TdExpr.floordivCalculate the floor on the division.
TdExpr.geGreater or equal operator.
TdExpr.gtGreater than operator.
TdExpr.hashCompute the hash of an element value.
TdExpr.is_betweenIf an expression is between the given bounds.
TdExpr.is_finiteIf an element value is finite.
TdExpr.is_inIf an element value is in the given collection.
TdExpr.is_infiniteIf an element value is infinite.
TdExpr.is_nanIf an element value is NaN.
TdExpr.is_not_nanIf an element value is not NaN.
TdExpr.is_not_nullIf an element value is not null (None).
TdExpr.is_nullIf an element value is null (None).
TdExpr.is_uniqueIf an element value is unique for all values in the column.
TdExpr.lastGet the last element.
TdExpr.leLess or equal operator.
TdExpr.lenAggregation operation that counts the rows in the group.
TdExpr.logCalculate the logarithm to the given base.
TdExpr.log10Calculate the logarithm base 10.
TdExpr.log1pCalculate the natural logarithm plus one.
TdExpr.ltLess than operator.
TdExpr.maxAggregation operation that finds the maximum value in the group.
TdExpr.meanAggregation operation that finds the mean of the values in the group.
TdExpr.medianAggregation operation that finds the median of the values in the group.
TdExpr.minAggregation operation that finds the minimum value in the group.
TdExpr.modModulus operator.
TdExpr.mulMultiplication operator.
TdExpr.n_uniqueAggregation operation that counts the unique values of the given column in the group.
TdExpr.neCompare if 2 expressions are not equal, equivalent to expr != other.
TdExpr.ne_missingCompare if 2 expressions are not equal an, equivalent to expr != other.
TdExpr.negUnary minus operator.
TdExpr.not_Negate a boolean expression.
TdExpr.or_Bitwise or operator with the given expressions.
TdExpr.powExponentiation operator.
TdExpr.radiansConvert a degree value to radians
TdExpr.rankCompute the rank of the element values.
TdExpr.reinterpretReinterpret the 64bit element values (i64 or u64) as a signed/unsigned integers.
TdExpr.roundRound floating point element values.
TdExpr.round_sig_figsRound floating point element values to the specified significant figures.
TdExpr.shrink_dtypeCast down a column to the smallest type that can hold the element values.
TdExpr.signCalculate the sign of element values.
TdExpr.sinCalculate the sine of the element value.
TdExpr.sinhCalculate the hyperbolic sine of the element value.
TdExpr.sliceCompute a slice of the TableFrame for the specified columns.
TdExpr.sqrtCalculate the square root of the element value.
TdExpr.subEquivalent to the - operator.
TdExpr.sumAggregation operation that sums the values in the group.
TdExpr.tanCalculate the tangent of the element value.
TdExpr.tanhCalculate the hyperbolic tangent of the element value.
TdExpr.truedivEquivalent to the float / operator.
TdExpr.xorBitwise xor operator with the given expression.

ErrorCode

class ErrorCode(*args, **kwds)

Bases: Enum


TableFrameError

class TableFrameError(error_code: ErrorCode, *args)

Bases: TabsDataException

Exception raised when handling a (Td)TableFrame.


TdExpr

class TdExpr(expr: Expr | TdExpr)

property
dtTdExprDateTimeNameSpace

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

property
strTdExprStringNameSpace

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

abs
def abs() -> TdExpr

Return the abso lute value of the expression.

add
def add(other: Any) -> TdExpr

Equivalent to the + operator.

For numeric types adds the given input. For string types concatenates the given input.

Parameters:

parameter
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 │
╞══════╪══════════╡
12
1516
1819
6061
6061
7576
│ null ┆ null │
└──────┴──────────┘

alias
def alias(name: str) -> TdExpr

Set the name for a column or expression.

Parameters:

parameter
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 │
╞══════╪══════╡
11
1515
1818
6060
6060
7575
│ null ┆ null │
└──────┴──────┘

and_
def and_(*others: Any) -> TdExpr

Bitwise and operator with the given expressions. It can be used with integer and bool types.

Parameters:

parameter
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 │
╞══════╪══════╡
-12
22
-30
00
50
72
│ null ┆ null │
└──────┴──────┘

arccos
def arccos() -> TdExpr

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.011.560796
0.151.420228
0.181.38981
0.60.927295
0.60.927295
0.750.722734
│ null ┆ null │
└──────┴──────────┘

arccosh
def arccosh() -> TdExpr

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.50.962424
1.81.192911
6.02.477889
6.02.477889
7.52.703576
│ null ┆ null │
└──────┴──────────┘

arcsin
def arcsin() -> TdExpr

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.010.01
0.150.150568
0.180.180986
0.60.643501
0.60.643501
0.750.848062
│ null ┆ null │
└──────┴──────────┘

arcsinh
def arcsinh() -> TdExpr

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.10.099834
1.51.194763
1.81.350441
6.02.49178
6.02.49178
7.52.712465
│ null ┆ null │
└──────┴──────────┘

arctan
def arctan() -> TdExpr

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.010.01
0.150.14889
0.180.178093
0.60.54042
0.60.54042
0.750.643501
│ null ┆ null │
└──────┴──────────┘

arctanh
def arctanh() -> TdExpr

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.010.01
0.150.15114
0.180.181983
0.60.693147
0.60.693147
0.750.972955
│ null ┆ null │
└──────┴──────────┘

cast
def cast(
dtype: PolarsDataType | type[Any],
strict: bool = True,
wrap_numerical: bool = False,
) -> TdExpr

Cast a value to d different type.

Parameters:

parameter
dtype

The data type to cast to.

parameter
strict

If false, invalid casts produce null's; if true, an excetion is raised.

parameter
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 │
╞══════╪══════╡
11.0
1515.0
1818.0
6060.0
6060.0
7575.0
│ null ┆ null │
└──────┴──────┘

cbrt
def cbrt() -> TdExpr

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 │
╞══════╪══════════╡
11.0
152.466212
182.620741
603.914868
603.914868
754.217163
│ null ┆ null │
└──────┴──────────┘

ceil
def ceil() -> TdExpr

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.01.0
1.12.0
└──────┴─────────┘

clip
def clip(
lower_bound: NumericLiteral | TemporalLiteral | IntoTdExprColumn | None = None,
upper_bound: NumericLiteral | TemporalLiteral | IntoTdExprColumn | None = None,
) -> TdExpr

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:

parameter
lower_bound

The lower bound value. If None, the lower bound is not set.

parameter
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 │
╞══════╪═══+++═══╡
118
1818
5050
6565
7065
└──────┴─────────┘

cos
def cos() -> TdExpr

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.10.995004
1.50.070737
1.8-0.227202
6.00.96017
6.00.96017
7.50.346635
│ null ┆ null │
└──────┴───────────┘

cosh
def cosh() -> TdExpr

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.11.005004
1.52.35241
1.83.107473
6.0201.715636
6.0201.715636
7.5904.021484
│ null ┆ null │
└──────┴────────────┘

cot
def cot() -> TdExpr

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.19.966644
1.50.070915
1.8-0.233304
6.0-3.436353
6.0-3.436353
7.50.369547
│ null ┆ null │
└──────┴───────────┘

count
def count() -> TdExpr

Aggregation operation that counts the non null values of the given column in the group.

Example:

>>> 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
def degrees() -> TdExpr

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.15.729578
1.585.943669
1.8103.132403
6.0343.774677
6.0343.774677
7.5429.718346
│ null ┆ null │
└──────┴────────────┘

diff
def diff(n: int = 1) -> TdExpr

Compute the difference between an element value and the element value of the specified relative row.

It supports numberic and datetime types.

Parameters:

parameter
n

The relative row to compute the difference with. Defaults to 1 (previous). Use a negative number to get a next row.

Example:

>>> 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
22
31
41
-1-5
-2-1
-3-1
-4-1
-5-1
│ null ┆ null │
└──────┴──────┘

eq
def eq(other: Any) -> TdExpr

Compare if 2 expressions are equal, equivalent to expr == other. If one of the expressions is null (None) it returns null.

Parameters:

parameter
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.02.0 ┆ false │
2.02.0 ┆ true │
│ NaN ┆ NaN ┆ true │
4.0 ┆ NaN ┆ false │
5.0 ┆ null ┆ null │
│ null┆ null ┆ null │
└─────┴──────┴───────┘

eq_missing
def eq_missing(other: Any) -> TdExpr

Compare if 2 expressions are equal an, equivalent to expr == other. If one of the expressions is null (None) it returns false.

Parameters:

parameter
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.02.0 ┆ false │
2.02.0 ┆ true │
│ NaN ┆ NaN ┆ true │
4.0 ┆ NaN ┆ false │
5.0 ┆ null ┆ false │
│ null┆ null ┆ true │
└─────┴──────┴───────────┘

exp
def exp() -> TdExpr

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.11.105171
6.0403.428793
6.0403.428793
7.51808.042414
│ null ┆ null │
└──────┴─────────────┘

fill_nan
def fill_nan(value: int | float | TdExpr | None) -> TdExpr

Replace NaN values with the given value.

Parameters:

parameter
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.11.1
2.02.0
│ inf ┆ inf │
│ null ┆ null │
│ NaN ┆ 5.5
└──────┴──────────┘

fill_null
def fill_null(
value: Any | TdExpr | None = None,
strategy: FillNullStrategy | None = None,
limit: int | None = None,
) -> TdExpr

Replace null values with the given value.

Parameters:

parameter
value

The value to replace null values with.

parameter
strategy

The strategy to use for filling null values.

parameter
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.00.0
1.11.1
2.02.0
│ inf ┆ inf │
│ null ┆ 5.5
│ NaN ┆ NaN │
└──────┴───────────┘

filter
def filter(*predicates: IntoTdExprColumn | Iterable[IntoTdExprColumn]) -> TdExpr

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:

parameter
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
def first() -> TdExpr

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 │
╞══════╪═════════╡
1010
1110
1810
6510
7010
└──────┴─────────┘

floor
def floor() -> TdExpr

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.01
1.11
└──────┴─────────┘

floordiv
def floordiv(other: Any) -> TdExpr

Calculate the floor on the division.

Parameters:

parameter
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.51
1.40
└──────┴──────────┘

ge
def ge(other: Any) -> TdExpr

Greater or equal operator.

Parameters:

parameter
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
def gt(other: Any) -> TdExpr

Greater than operator.

Parameters:

parameter
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
def hash(
seed: int = 0,
seed_1: int | None = None,
seed_2: int | None = None,
seed_3: int | None = None,
) -> TdExpr

Compute the hash of an element value.

Parameters:

parameter
seed

The seed for the hash function.

parameter
seed_1

The first seed for the hash function.

parameter
seed_2

The second seed for the hash function.

parameter
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.11438840365631752616
2.04738789230185236462
└──────┴─────────────────────┘

is_between
def is_between(
lower_bound: IntoTdExpr,
upper_bound: IntoTdExpr,
closed: ClosedInterval = 'both',
) -> TdExpr

If an expression is between the given bounds.

Parameters:

parameter
lower_bound

The lower bound value.

parameter
upper_bound

The upper bound value.

parameter
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
def is_finite() -> TdExpr

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
def is_in(other: TdExpr | Collection[Any] | Series) -> TdExpr

If an element value is in the given collection.

Parameters:

parameter
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
def is_infinite() -> TdExpr

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
def is_nan() -> TdExpr

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
def is_not_nan() -> TdExpr

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
def is_not_null() -> TdExpr

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
def is_null() -> TdExpr

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
def is_unique() -> TdExpr

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
def last() -> TdExpr

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 │
╞══════╪═════════╡
1070
1170
1870
6570
7070
└──────┴─────────┘

le
def le(other: Any) -> TdExpr

Less or equal operator.

Parameters:

parameter
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
def len() -> TdExpr

Aggregation operation that counts the rows in the group.

Example:

>>> 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
def log(base: float = 2.718281828459045) -> TdExpr

Calculate the logarithm to the given base.

Parameters:

parameter
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.10.09531
2.00.693147
│ inf ┆ inf │
│ null ┆ null │
│ NaN ┆ NaN │
└──────┴──────────┘

log10
def log10() -> TdExpr

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.10.041393
2.00.30103
│ inf ┆ inf │
│ null ┆ null │
│ NaN ┆ NaN │
└──────┴──────────┘

log1p
def log1p() -> TdExpr

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.00.0
1.10.741937
2.01.098612
│ inf ┆ inf │
│ null ┆ null │
│ NaN ┆ NaN │
└──────┴──────────┘

lt
def lt(other: Any) -> TdExpr

Less than operator.

Parameters:

parameter
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
def max() -> TdExpr

Aggregation operation that finds the maximum value in the group.

Example:

>>> 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
def mean() -> TdExpr

Aggregation operation that finds the mean of the values in the group.

Example:

>>> 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
def median() -> TdExpr

Aggregation operation that finds the median of the values in the group.

Example:

>>> 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
def min() -> TdExpr

Aggregation operation that finds the minimum value in the group.

Example:

>>> 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
def mod(other: Any) -> TdExpr

Modulus operator.

Parameters:

parameter
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 │
╞══════╪══════╡
11
150
183
│ null ┆ null │
└──────┴──────┘

mul
def mul(other: Any) -> TdExpr

Multiplication operator.

Parameters:

parameter
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 │
╞══════╪══════╡
110
15150
18180
75750
│ null ┆ null │
└──────┴──────┘

n_unique
def n_unique() -> TdExpr

Aggregation operation that counts the unique values of the given column in the group.

Example:

>>> 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
def ne(other: Any) -> TdExpr

Compare if 2 expressions are not equal, equivalent to expr != other. If one of the expressions is null (None) it returns null.

Parameters:

parameter
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.02.0 ┆ true │
2.02.0 ┆ false │
│ NaN ┆ NaN ┆ false │
4.0 ┆ NaN ┆ true │
5.0 ┆ null ┆ null │
│ null┆ null ┆ null │
└─────┴──────┴───────┘

ne_missing
def ne_missing(other: Any) -> TdExpr

Compare if 2 expressions are not equal an, equivalent to expr != other. If one of the expressions is null (None) it returns false.

Parameters:

parameter
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.02.0 ┆ true │
2.02.0 ┆ false │
│ NaN ┆ NaN ┆ false │
4.0 ┆ NaN ┆ true │
5.0 ┆ null ┆ true │
│ null┆ null ┆ false │
└─────┴──────┴───────────┘

neg
def neg() -> TdExpr

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.01.0
0.0-0.0
1.1-1.1
2.0-2.0
│ inf ┆ -inf │
│ null ┆ null │
│ NaN ┆ NaN │
└──────┴──────┘

not_
def not_() -> TdExpr

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
------
boolbool
╞═══════╪═══════╡
│ true ┆ false │
│ false ┆ true │
│ null ┆ null │
└───────┴───────┘

or_
def or_(*others: Any) -> TdExpr

Bitwise or operator with the given expressions. It can be used with integer and bool types.

Parameters:

parameter
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 │
╞══════╪══════╡
11
1515
1819
6061
│ null ┆ null │
└──────┴──────┘

pow
def pow(exponent: IntoTdExprColumn | int | float) -> TdExpr

Exponentiation operator.

Parameters:

parameter
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 │
╞══════╪══════╡
11
15225
18324
603600
│ null ┆ null │
└──────┴──────┘

radians
def radians() -> TdExpr

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 │
╞═════════╪══════════╡
10.017453
150.261799
601.047198
751.308997
│ null ┆ null │
└─────────┴──────────┘

rank
def rank(
method: RankMethod = 'average',
descending: bool = False,
seed: int | None = None,
) -> TdExpr

Compute the rank of the element values. Multiple rank types are available.

Parameters:

parameter
method

the ranking type: 'average' (default), 'dense', 'max', 'min', 'ordinal' or 'random'.

parameter
descending

if the order is ascending (default) or descending.

parameter
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.01
0.02
1.13
2.04
│ inf ┆ 5
│ null ┆ null │
│ NaN ┆ 6
└──────┴──────┘

reinterpret
def reinterpret(signed: bool = True) -> TdExpr

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

Parameters:

parameter
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 │
╞══════╪═════════════╡
33
11
55
44
22
66
│ null ┆ null │
└──────┴─────────────┘

round
def round(decimals: int = 0) -> TdExpr

Round floating point element values.

Parameters:

parameter
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.00.0
1.11.0
2.02.0
│ inf ┆ inf │
│ null ┆ null │
│ NaN ┆ NaN │
└──────┴───────┘

round_sig_figs
def round_sig_figs(digits: int) -> TdExpr

Round floating point element values to the specified significant figures.

Parameters:

parameter
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.01230.012
2.02442.0
0.00.0
│ inf ┆ NaN │
50.050.0
1.01.0
│ NaN ┆ NaN │
│ null ┆ null │
112.0110.0
2142.02100.0
└────────┴────────────────┘

shrink_dtype
def shrink_dtype() -> TdExpr

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 │
╞═══════╪══════════════╡
00
256256
6502565025
└───────┴──────────────┘

sign
def sign() -> TdExpr

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.01231.0
2.02441.0
0.00.0
│ inf ┆ 1.0
-50.0-1.0
1.01.0
│ NaN ┆ NaN │
│ null ┆ null │
-112.0-1.0
2142.01.0
└────────┴──────┘

sin
def sin() -> TdExpr

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 │
╞═════╪═══════════╡
00.0
30-0.988032
60-0.304811
900.893997
└─────┴───────────┘

sinh
def sinh() -> TdExpr

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 │
╞═════╪═══════════╡
00.0
305.3432e12
605.7100e25
906.1020e38
└─────┴───────────┘

slice
def slice(offset: int | TdExpr, length: int | TdExpr | None = None) -> TdExpr

Compute a slice of the TableFrame for the specified columns.

Parameters:

parameter
offset

the offset to start the slice.

parameter
length

the length of the slice.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ x ┆ y │
------
│ f64 ┆ f64 │
╞══════╪══════╡
1.02.0
2.02.0
│ NaN ┆ NaN │
4.0 ┆ NaN │
5.0 ┆ null │
│ null ┆ null │
└──────┴──────┘
>>>
>>> tf.select(tf.all().slice(1,2))
>>>
┌─────┬─────┐
│ x ┆ y │
------
│ f64 ┆ f64 │
╞═════╪═════╡
2.02.0
│ NaN ┆ NaN │
└─────┴─────┘

sqrt
def sqrt() -> TdExpr

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.01.0
2.01.414214
│ NaN ┆ NaN │
4.02.0
5.02.236068
│ null ┆ null │
└──────┴──────────┘

sub
def sub(other: Any) -> TdExpr

Equivalent to the - operator.

Parameters:

parameter
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 │
╞══════╪══════════╡
10
1514
1817
6059
6059
7574
│ null ┆ null │
└──────┴──────────┘

sum
def sum() -> TdExpr

Aggregation operation that sums the values in the group.

Example:

>>> 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
def tan() -> TdExpr

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 │
╞═════╪═══════════╡
00.0
30-6.405331
600.32004
90-1.9952
└─────┴───────────┘

tanh
def tanh() -> TdExpr

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.00.0
3.00.995055
6.00.999988
9.01.0
└─────┴──────────┘

truediv
def truediv(other: Any) -> TdExpr

Equivalent to the float / operator.

Parameters:

parameter
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.01230.0041
2.02440.6748
0.00.0
│ inf ┆ inf │
-50.0-16.666667
1.00.333333
│ NaN ┆ NaN │
│ null ┆ null │
-112.0-37.333333
2142.0714.0
└────────┴────────────┘

xor
def xor(other: Any) -> TdExpr

Bitwise xor operator with the given expression. It can be used with integer and bool types.

Parameters:

parameter
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 │
╞═════╪═════╡
08
3022
6052
9082
└─────┴─────┘