Logic

Expr.and_(
*others: Any,
) Expr
Categories:

logic

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

Parameters:

others – expressions to peform the bitwise and with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("i"), td.col("i").and_(2).alias("and_"))
>>>
┌──────┬──────┐
│ i    ┆ and_ │
│ ---  ┆ ---  │
│ i64  ┆ i64  │
╞══════╪══════╡
│ -1   ┆ 2    │
│ 2    ┆ 2    │
│ -3   ┆ 0    │
│ 0    ┆ 0    │
│ 5    ┆ 0    │
│ 7    ┆ 2    │
│ null ┆ null │
└──────┴──────┘
Expr.eq(
other: Any,
) Expr
Categories:

logic

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

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("a").eq(td.col("b")).alias("eq"))
>>>
┌─────┬──────┬───────┐
│ a   ┆ b    ┆ eq    │
│ --- ┆ ---  ┆ ---   │
│ f64 ┆ f64  ┆ bool  │
╞═════╪══════╪═══════╡
│ 1.0 ┆ 2.0  ┆ false │
│ 2.0 ┆ 2.0  ┆ true  │
│ NaN ┆ NaN  ┆ true  │
│ 4.0 ┆ NaN  ┆ false │
│ 5.0 ┆ null ┆ null  │
│ null┆ null ┆ null  │
└─────┴──────┴───────┘
Expr.eq_missing(
other: Any,
) Expr
Categories:

logic

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

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("a").eq(td.col("b")).alias("eq_missing"))
>>>
┌─────┬──────┬───────────┐
│ a   ┆ b    ┆ eq_missing│
│ --- ┆ ---  ┆ ---       │
│ f64 ┆ f64  ┆ bool      │
╞═════╪══════╪═══════════╡
│ 1.0 ┆ 2.0  ┆ false     │
│ 2.0 ┆ 2.0  ┆ true      │
│ NaN ┆ NaN  ┆ true      │
│ 4.0 ┆ NaN  ┆ false     │
│ 5.0 ┆ null ┆ false     │
│ null┆ null ┆ true      │
└─────┴──────┴───────────┘
Expr.ge(
other: Any,
) Expr
Categories:

logic

Greater or equal operator.

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").ge(1.0).alias("ge"))
>>>
┌──────┬─────────┐
│ temp ┆ ge      │
│ ---  ┆ ------- │
│ f64  ┆ bool    │
╞══════╪═════════╡
│ 0.9  ┆  false  │
│ 1.1  ┆  true   │
└──────┴─────────┘
Expr.gt(
other: Any,
) Expr
Categories:

logic

Greater than operator.

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").gt(1.0).alias("gt"))
>>>
┌──────┬─────────┐
│ temp ┆ ge      │
│ ---  ┆ ------- │
│ f64  ┆ bool    │
╞══════╪═════════╡
│ 1.0  ┆  false  │
│ 1.1  ┆  true   │
└──────┴─────────┘
Expr.is_between(
lower_bound: td_typing.IntoExpr,
upper_bound: td_typing.IntoExpr,
closed: td_typing.ClosedInterval = 'both',
) Expr
Categories:

logic

If an expression is between the given bounds.

Parameters:
  • lower_bound – The lower bound value.

  • upper_bound – The upper bound value.

  • closed – The interval type, either “both”, “left”, “right”, or “neither”

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp")
>>> .is_between(0, 1).alias("between"))
>>>
┌──────┬─────────┐
│ temp ┆ between │
│ ---  ┆ ------- │
│ f64  ┆ bool    │
╞══════╪═════════╡
│-1.0  ┆  false  │
│ 0.0  ┆  true   │
│ 0.5  ┆  true   │
│ 1.0  ┆  true   │
│ 1.1  ┆  false  │
└──────┴─────────┘
Expr.is_finite() Expr
Categories:

logic

If an element value is finite.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_finite()
>>>        .alias("finite"))
>>>
┌──────┬────────┐
│ temp ┆ finite │
│ ---  ┆ ---    │
│ f64  ┆ bool   │
╞══════╪════════╡
│ 1.1  ┆ true   │
│ 2.0  ┆ true   │
│ inf  ┆ false  │
└──────┴────────┘
Expr.is_in(
other: Expr | Collection[Any],
) Expr
Categories:

logic

If an element value is in the given collection.

Parameters:

other – The collection to check if the element value is in.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_in([1.1, 2.2])
>>>        .alias("is_in"))
>>>
┌──────┬────────┐
│ temp ┆ is_in  │
│ ---  ┆ ---    │
│ f64  ┆ bool   │
╞══════╪════════╡
│ 1.1  ┆ true   │
│ 2.0  ┆ false  │
│ inf  ┆ false  │
└──────┴────────┘
Expr.is_infinite() Expr
Categories:

logic

If an element value is infinite.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp")
>>>        .is_infinite().alias("infinite"))
>>>
┌──────┬──────────┐
│ temp ┆ infinite │
│ ---  ┆ ---      │
│ f64  ┆ bool     │
╞══════╪══════════╡
│ 1.1  ┆ false    │
│ 2.0  ┆ false    │
│ inf  ┆ true     │
└──────┴──────────┘
Expr.is_nan() Expr
Categories:

logic

If an element value is NaN.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_nan().alias("nan"))
>>>
┌──────┬──────────┐
│ temp ┆ nan      │
│ ---  ┆ ---      │
│ f64  ┆ bool     │
╞══════╪══════════╡
│ 1.1  ┆ false    │
│ Nan  ┆ true     │
│ None ┆ false    │
│ inf  ┆ false    │
└──────┴──────────┘
Expr.is_not_nan() Expr
Categories:

logic

If an element value is not NaN.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_not_nan()
>>>        .alias("not_nan"))
>>>
┌──────┬──────────┐
│ temp ┆ not_nan  │
│ ---  ┆ ---      │
│ f64  ┆ bool     │
╞══════╪══════════╡
│ 1.1  ┆ true     │
│ Nan  ┆ false    │
│ None ┆ false    │
│ inf  ┆ true     │
└──────┴──────────┘
Expr.is_not_null() Expr
Categories:

logic

If an element value is not null (None).

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_not_null()
>>>        .alias("null"))
>>>
┌──────┬──────────┐
│ temp ┆ not_nulL │
│ ---  ┆ ---      │
│ f64  ┆ bool     │
╞══════╪══════════╡
│ 1.1  ┆ true     │
│ Nan  ┆ true     │
│ None ┆ false    │
│ inf  ┆ true     │
└──────┴──────────┘
Expr.is_null() Expr
Categories:

logic

If an element value is null (None).

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_not_null()
>>>        .alias("null"))
>>>
┌──────┬──────────┐
│ temp ┆ null     │
│ ---  ┆ ---      │
│ f64  ┆ bool     │
╞══════╪══════════╡
│ 1.1  ┆ false    │
│ Nan  ┆ false    │
│ None ┆ true     │
│ inf  ┆ false    │
└──────┴──────────┘
Expr.is_unique() Expr
Categories:

logic

If an element value is unique for all values in the column.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").is_unique()
>>>        .alias("unique"))
>>>
┌──────┬──────────┐
│ temp ┆ unique   │
│ ---  ┆ ---      │
│ f64  ┆ bool     │
╞══════╪══════════╡
│ 1.1  ┆ false    │
│ 1.1  ┆ false    │
│ None ┆ true     │
│ 2.0  ┆ true     │
└──────┴──────────┘
Expr.le(
other: Any,
) Expr
Categories:

logic

Less or equal operator.

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("temp"), td.col("temp").le(1.0).alias("le"))
>>>
┌──────┬─────────┐
│ temp ┆ le      │
│ ---  ┆ ------- │
│ f64  ┆ bool    │
╞══════╪═════════╡
│ 0.9  ┆  true   │
│ 1.1  ┆  false  │
└──────┴─────────┘
Expr.lt(
other: Any,
) Expr
Categories:

logic

Less than operator.

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("val"), td.col("val").lt(1.0).alias("lt"))
>>>
┌──────┬─────────┐
│ val  ┆ tl      │
│ ---  ┆ ------- │
│ f64  ┆ bool    │
╞══════╪═════════╡
│ 1.0  ┆  false  │
│ 0.1  ┆  true   │
└──────┴─────────┘
Expr.ne(
other: Any,
) Expr
Categories:

logic

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

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("a").ne(td.col("b")).alias("ne"))
>>>
┌─────┬──────┬───────┐
│ a   ┆ b    ┆ ne    │
│ --- ┆ ---  ┆ ---   │
│ f64 ┆ f64  ┆ bool  │
╞═════╪══════╪═══════╡
│ 1.0 ┆ 2.0  ┆ true  │
│ 2.0 ┆ 2.0  ┆ false │
│ NaN ┆ NaN  ┆ false │
│ 4.0 ┆ NaN  ┆ true  │
│ 5.0 ┆ null ┆ null  │
│ null┆ null ┆ null  │
└─────┴──────┴───────┘
Expr.ne_missing(
other: Any,
) Expr
Categories:

logic

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

Parameters:

other – The value to compare with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("a").eq(td.col("b")).alias("ne_missing"))
>>>
┌─────┬──────┬───────────┐
│ a   ┆ b    ┆ ne_missing│
│ --- ┆ ---  ┆ ---       │
│ f64 ┆ f64  ┆ bool      │
╞═════╪══════╪═══════════╡
│ 1.0 ┆ 2.0  ┆ true      │
│ 2.0 ┆ 2.0  ┆ false     │
│ NaN ┆ NaN  ┆ false     │
│ 4.0 ┆ NaN  ┆ true      │
│ 5.0 ┆ null ┆ true      │
│ null┆ null ┆ false     │
└─────┴──────┴───────────┘
Expr.not_() Expr
Categories:

logic

Negate a boolean expression.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("val"), td.col("val").not_().alias("not"))
>>>
┌───────┬───────┐
│ val   ┆ not   │
│ ---   ┆ ---   │
│ bool  ┆ bool  │
╞═══════╪═══════╡
│ true  ┆ false │
│ false ┆ true  │
│ null  ┆ null  │
└───────┴───────┘
Expr.or_(
*others: Any,
) Expr
Categories:

logic

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

Parameters:

others – expressions to peform the bitwise or with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf = tf.select(td.col("val"), td.col("val").or_(1).alias("or"))
>>>
┌──────┬──────┐
│ val  ┆ or   │
│ ---  ┆ ---  │
│ i64  ┆ i64  │
╞══════╪══════╡
│ 1    ┆ 1    │
│ 15   ┆ 15   │
│ 18   ┆ 19   │
│ 60   ┆ 61   │
│ null ┆ null │
└──────┴──────┘
Expr.xor(
other: Any,
) Expr
Categories:

logic

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

Parameters:

other – expression to peform the bitwise xor with.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("val"), td.col("val").xor(8).alias("xor"))
>>>
┌─────┬─────┐
│ val ┆ xor │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 0   ┆ 8   │
│ 30  ┆ 22  │
│ 60  ┆ 52  │
│ 90  ┆ 82  │
└─────┴─────┘