Eval  type: eval#

class lumen.transforms.base.Eval(*, expr, controls, name)#

Applies an eval assignment expression to a DataFrame. The expression can reference columns on the original table by referencing table.<column> and must assign to a variable that will become a new column in the DataFrame, e.g. to divide a value column by one thousand and assign the result to a new column called kilo_value you can write an expr like:

kilo_value = table.value / 1000

See pandas.eval for more information.


Parameters#

expr

type: str
default: ''
The expression to apply to the table.


Methods#

Eval.apply(table: DataFrame) DataFrame#

Given a table transform it in some way and return it.

Parameters:

table (DataFrame) – The queried table as a DataFrame.

Returns:

A DataFrame containing the transformed data.

Return type:

DataFrame

Eval.to_spec(context: Dict[str, Any] | None = None) Dict[str, Any]#

Exports the full specification to reconstruct this component.

Return type:

Resolved and instantiated Component object