TableFrame Functions#

TableFrame Column Functions#

class TdCol[source]#

Bases: object

This class is used to create TableFrame column expressions.

An instance of this class is available as col. It can be called like a function (e.g., td.col(“name”)). For more information, refer to the __call__ method documentation.

This helper class provides an alternative way to create column expressions using attribute lookup. For instance, col.name is equivalent to col(“name”). Refer to __getattr__() method.

Example: >>> import tabsdata as td >>> >>> tf: td.TableFrame … >>> >>> tf = tf.with_columns(full_name=(td.col(“last_name”) + “, “ + >>> td.col(“first_name”))

TableFrame DateTime Functions#

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]#

TableFrame Eager Functions#

concat(items: Iterable[TdPolarsType]) TdPolarsType[source]#

Combine multiple TableFrames by stacking their rows.

Parameters:

items – The TableFrames to concatenate.

Example:

>>> import tabsdata as td
>>>
>>> tf1: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ a    ┆ 1    │
│ b    ┆ 2    │
└──────┴──────┘
>>>
>>> tf2: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ x    ┆ 10   │
│ y    ┆ 20   │
└──────┴──────┘
>>>
>>> tf = td.concat(tf1, tf2)
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ a    ┆ 1    │
│ b    ┆ 2    │
│ x    ┆ 10   │
│ y    ┆ 20   │
└──────┴──────┘

TableFrame Lit Functions#

lit(value: Any, dtype: PolarsDataType | None = None, *, allow_object: bool = False) td_expr.TdExpr[source]#

Expression for the given literal value.

Parameters:
  • value – The literal value.

  • dtype – The data type of the literal value.

  • allow_object – Whether to allow object data type.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.lit("Hi").alias("lit"), td.col("age").alias("Age"))
>>>
┌──────┬──────┐
│ lit  ┆ Age  │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ Hi   ┆ 1    │
│ Hi   ┆ 15   │
│ Hi   ┆ 18   │
│ Hi   ┆ null │
└──────┴──────┘