lt_toolbox.TrajFrame.compute_grouped_expr#

TrajFrame.compute_grouped_expr(group: str, expr: Expr, alias: str, append: bool = False) Self[source]#

Compute polars expression over groups.

Parameters:
  • group (str) – Name of column variable to group according to unique values. The expression will be computed for each group member.

  • expr (Expression) – Compute expression to aggregate each group.

  • alias (str) – Name of output statistic from computing grouped expression.

  • append (bool, default: False) – If set to True, the grouped expression will be appended to the existing summary_data, otherwise summary_data will be replaced with a new DataSet.

Returns:

TrajFrame is returned with the computed grouped expression included in the summary_data where the groups are given as the coordinate dimension.

Return type:

TrajFrame

Examples

Calculating summed volume transport of Lagrangian trajectories grouped by the start_date column variable.

>>> expr = pl.col('vol').sum()
>>> trajectories.compute_grouped_expr(group='start_date', expr=expr)