Transform#

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

Transform components implement transforms of DataFrame objects.


Parameters#

controls

type: list[Any]
default: []
Parameters that should be exposed as widgets in the UI.

name

type: str
default: 'Transform'
String identifier for this object.


Methods#

Transform.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

Transform.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

Types#

Filter type: None

Filter transform implement the filtering behavior of Filter components.

HistoryTransform type: history

HistoryTransform accumulates a history of the queried data.

Aggregate type: aggregate

Aggregate one or more columns or indexes, see pandas.DataFrame.groupby.

Sort type: sort

Sort on one or more columns, see pandas.DataFrame.sort_values.

Query type: query

Query applies the pandas.DataFrame.query method.

Columns type: columns

Columns selects a subset of columns.

Astype type: as_type

Astype transforms the type of one or more columns.

Stack type: stack

Stack applies pandas.DataFrame.stack to the declared level.

Unstack type: unstack

Unstack applies pandas.DataFrame.unstack to the declared level.

Iloc type: iloc

Iloc applies integer slicing to the data, see pandas.DataFrame.iloc.

Sample type: sample

Sample returns a random sample of items.

Compute type: compute

Compute turns a dask.dataframe.DataFrame into a pandas.DataFrame.

Pivot type: pivot

Pivot applies pandas.DataFrame.pivot given an index, columns, and values.

Melt type: melt

Melt applies the pandas.melt operation given the id_vars and value_vars.

SetIndex type: set_index

SetIndex promotes DataFrame columns to indexes, see pandas.DataFrame.set_index.

ResetIndex type: reset_index

ResetIndex resets DataFrame indexes to columns or drops them, see pandas.DataFrame.reset_index

Rename type: rename

Rename renames columns or indexes, see pandas.DataFrame.rename.

RenameAxis type: rename_axis

Set the name of the axis for the index or columns,

Count type: count

Counts non-nan values in each column of the DataFrame and returns

Sum type: sum

Sums numeric values in each column of the DataFrame and returns a

Eval type: eval

Applies an eval assignment expression to a DataFrame. The

project_lnglat type: project_lnglat

project_lnglat projects the given longitude/latitude columns to Web Mercator.

SQLGroupBy type: sql_group_by

Performs a Group-By and aggregation

SQLLimit type: sql_limit

Performs a LIMIT SQL operation on the query

SQLDistinct type: sql_distinct

SQLDistinct Transform

SQLMinMax type: sql_minmax

SQLMinMax Transform

SQLColumns type: sql_columns

SQLColumns Transform

SQLFilter type: sql_filter

Translates Lumen Filter query into a SQL WHERE statement.