tabsdata.tableframe.udf.function
UDF | |
UDF.columns | |
UDF.on_batch | Creating UDFs: |
UDF.on_element | Creating UDFs: |
UDF.with_columns | |
UDFList | Abstract base class for UDFs that use list-style parameter passing. |
UDFList.columns | |
UDFList.on_batch | Creating UDFs: |
UDFList.on_element | Creating UDFs: |
UDFList.with_columns | |
UDFUnpacked | Abstract base class for UDFs that use unpacked-style parameter passing. |
UDFUnpacked.columns | |
UDFUnpacked.on_batch | Creating UDFs: |
UDFUnpacked.on_element | Creating UDFs: |
UDFUnpacked.with_columns |
UDF
class UDF(
output_columns: list[tuple[str, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64]] | tuple[str, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64],
)
Bases: ABC
signatureLiteral['list', 'unpacked']Defines how parameters are passed to on_batch and on_element methods.
Returns: "list": Parameters are passed as a single list (default). "unpacked": Each parameter is passed as a separate argument.
Override this property in your UDF subclass to change the parameter style.
columnsdef columns(
,
) -> list[tuple[str, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64]]
on_batchdef on_batch(*args) -> list[Series]
Creating UDFs:
- Subclass :class:
tabsdata.tableframe.udf.function.UDF. - Implement
__init__to callsuper().__init__(output_columns)whereoutput_columnsis a tuple or list of tuples(name, data type)specifying the UDF default output schema (column names and data types). Each tuple must contain a column name (string) and a data type (DataType). - Override exactly one of
on_batchoron_element, to implement the UDF function logic. - Return a list of TabsData Series (for
on_batch) or TabsData supported scalars (foron_element) with the same length as specified in the output schema. - If overriding the
on_batchmethod, the return type must be a list of TabsData Series. If overriding theon_elementmethod, the return type must be a list of supported TabsData scalar values. For both cases, the number of elements in the returned lists must match the number of elements in the output_columns list provided to the UDF constructor.
Using UDFs:
- Instantiate a function created as above.
- Pass it to TableFrame method udf().
- Optionally use :meth:
UDF.output_columnsto override output column names or data types after instantiation. - By default,
on_batchreceives a list of series. Override thesignatureproperty to return "unpacked" to receive each series as a separate argument instead.
on_elementdef on_element(*args) -> list[Any]
Creating UDFs:
- Subclass :class:
tabsdata.tableframe.udf.function.UDF. - Implement
__init__to callsuper().__init__(output_columns)whereoutput_columnsis a tuple or list of tuples(name, data type)specifying the UDF default output schema (column names and data types). Each tuple must contain a column name (string) and a data type (DataType). - Override exactly one of
on_batchoron_element, to implement the UDF function logic. - Return a list of TabsData Series (for
on_batch) or TabsData supported scalars (foron_element) with the same length as specified in the output schema. - If overriding the
on_batchmethod, the return type must be a list of TabsData Series. If overriding theon_elementmethod, the return type must be a list of supported TabsData scalar values. For both cases, the number of elements in the returned lists must match the number of elements in the output_columns list provided to the UDF constructor.
Using UDFs:
- Instantiate a function created as above.
- Pass it to TableFrame method udf().
- Optionally use :meth:
UDF.output_columnsto override output column names or data types after instantiation. - By default,
on_elementreceives a list of values. Override thesignatureproperty to return "unpacked" to receive each value as a separate argument instead.
with_columnsdef with_columns(
output_columns: tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType] | list[tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType]] | dict[int, tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType]],
) -> UDF
UDFList
class UDFList(output_columns)
Bases: UDF, ABC
Abstract base class for UDFs that use list-style parameter passing.
When subclassing UDFList, implement on_batch or on_element with list signature:
on_batch(self, series: list[Series]) -> list[Series]on_element(self, values: list[Any]) -> list[Any]
signatureLiteral['list', 'unpacked']Defines how parameters are passed to on_batch and on_element methods.
Returns: "list": Parameters are passed as a single list (default). "unpacked": Each parameter is passed as a separate argument.
Override this property in your UDF subclass to change the parameter style.
columnsdef columns(
,
) -> list[tuple[str, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64]]
on_batchdef on_batch(*args) -> list[Series]
Creating UDFs:
- Subclass :class:
tabsdata.tableframe.udf.function.UDF. - Implement
__init__to callsuper().__init__(output_columns)whereoutput_columnsis a tuple or list of tuples(name, data type)specifying the UDF default output schema (column names and data types). Each tuple must contain a column name (string) and a data type (DataType). - Override exactly one of
on_batchoron_element, to implement the UDF function logic. - Return a list of TabsData Series (for
on_batch) or TabsData supported scalars (foron_element) with the same length as specified in the output schema. - If overriding the
on_batchmethod, the return type must be a list of TabsData Series. If overriding theon_elementmethod, the return type must be a list of supported TabsData scalar values. For both cases, the number of elements in the returned lists must match the number of elements in the output_columns list provided to the UDF constructor.
Using UDFs:
- Instantiate a function created as above.
- Pass it to TableFrame method udf().
- Optionally use :meth:
UDF.output_columnsto override output column names or data types after instantiation. - By default,
on_batchreceives a list of series. Override thesignatureproperty to return "unpacked" to receive each series as a separate argument instead.
on_elementdef on_element(*args) -> list[Any]
Creating UDFs:
- Subclass :class:
tabsdata.tableframe.udf.function.UDF. - Implement
__init__to callsuper().__init__(output_columns)whereoutput_columnsis a tuple or list of tuples(name, data type)specifying the UDF default output schema (column names and data types). Each tuple must contain a column name (string) and a data type (DataType). - Override exactly one of
on_batchoron_element, to implement the UDF function logic. - Return a list of TabsData Series (for
on_batch) or TabsData supported scalars (foron_element) with the same length as specified in the output schema. - If overriding the
on_batchmethod, the return type must be a list of TabsData Series. If overriding theon_elementmethod, the return type must be a list of supported TabsData scalar values. For both cases, the number of elements in the returned lists must match the number of elements in the output_columns list provided to the UDF constructor.
Using UDFs:
- Instantiate a function created as above.
- Pass it to TableFrame method udf().
- Optionally use :meth:
UDF.output_columnsto override output column names or data types after instantiation. - By default,
on_elementreceives a list of values. Override thesignatureproperty to return "unpacked" to receive each value as a separate argument instead.
with_columnsdef with_columns(
output_columns: tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType] | list[tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType]] | dict[int, tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType]],
) -> UDF
UDFUnpacked
class UDFUnpacked(output_columns)
Bases: UDF, ABC
Abstract base class for UDFs that use unpacked-style parameter passing.
When subclassing UDFUnpacked, implement on_batch or on_element with unpacked signature:
on_batch(self, col1: Series, col2: Series, ...) -> list[Series]on_element(self, val1: Any, val2: Any, ...) -> list[Any]
signatureLiteral['list', 'unpacked']Defines how parameters are passed to on_batch and on_element methods.
Returns: "list": Parameters are passed as a single list (default). "unpacked": Each parameter is passed as a separate argument.
Override this property in your UDF subclass to change the parameter style.
columnsdef columns(
,
) -> list[tuple[str, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64]]
on_batchdef on_batch(*args) -> list[Series]
Creating UDFs:
- Subclass :class:
tabsdata.tableframe.udf.function.UDF. - Implement
__init__to callsuper().__init__(output_columns)whereoutput_columnsis a tuple or list of tuples(name, data type)specifying the UDF default output schema (column names and data types). Each tuple must contain a column name (string) and a data type (DataType). - Override exactly one of
on_batchoron_element, to implement the UDF function logic. - Return a list of TabsData Series (for
on_batch) or TabsData supported scalars (foron_element) with the same length as specified in the output schema. - If overriding the
on_batchmethod, the return type must be a list of TabsData Series. If overriding theon_elementmethod, the return type must be a list of supported TabsData scalar values. For both cases, the number of elements in the returned lists must match the number of elements in the output_columns list provided to the UDF constructor.
Using UDFs:
- Instantiate a function created as above.
- Pass it to TableFrame method udf().
- Optionally use :meth:
UDF.output_columnsto override output column names or data types after instantiation. - By default,
on_batchreceives a list of series. Override thesignatureproperty to return "unpacked" to receive each series as a separate argument instead.
on_elementdef on_element(*args) -> list[Any]
Creating UDFs:
- Subclass :class:
tabsdata.tableframe.udf.function.UDF. - Implement
__init__to callsuper().__init__(output_columns)whereoutput_columnsis a tuple or list of tuples(name, data type)specifying the UDF default output schema (column names and data types). Each tuple must contain a column name (string) and a data type (DataType). - Override exactly one of
on_batchoron_element, to implement the UDF function logic. - Return a list of TabsData Series (for
on_batch) or TabsData supported scalars (foron_element) with the same length as specified in the output schema. - If overriding the
on_batchmethod, the return type must be a list of TabsData Series. If overriding theon_elementmethod, the return type must be a list of supported TabsData scalar values. For both cases, the number of elements in the returned lists must match the number of elements in the output_columns list provided to the UDF constructor.
Using UDFs:
- Instantiate a function created as above.
- Pass it to TableFrame method udf().
- Optionally use :meth:
UDF.output_columnsto override output column names or data types after instantiation. - By default,
on_elementreceives a list of values. Override thesignatureproperty to return "unpacked" to receive each value as a separate argument instead.
with_columnsdef with_columns(
output_columns: tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType] | list[tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType]] | dict[int, tuple[str | None, Boolean | Categorical | Date | Datetime | Decimal | Duration | Enum | Float16 | Float32 | Float64 | Int8 | Int16 | Int64 | Int32 | Int128 | Null | String | Time | UInt8 | UInt16 | UInt32 | UInt64 | NoneType]],
) -> UDF