polars_expr::prelude

Trait PartitionedAggregation

Source
pub trait PartitionedAggregation:
    Send
    + Sync
    + PhysicalExpr {
    // Required methods
    fn evaluate_partitioned(
        &self,
        df: &DataFrame,
        groups: &GroupsProxy,
        state: &ExecutionState,
    ) -> PolarsResult<Series>;
    fn finalize(
        &self,
        partitioned: Series,
        groups: &GroupsProxy,
        state: &ExecutionState,
    ) -> PolarsResult<Series>;
}

Required Methods§

Source

fn evaluate_partitioned( &self, df: &DataFrame, groups: &GroupsProxy, state: &ExecutionState, ) -> PolarsResult<Series>

This is called in partitioned aggregation. Partitioned results may differ from aggregation results. For instance, for a mean operation a partitioned result needs to return the sum and the valid_count (length - null count).

A final aggregation can then take the sum of sums and sum of valid_counts to produce a final mean.

Source

fn finalize( &self, partitioned: Series, groups: &GroupsProxy, state: &ExecutionState, ) -> PolarsResult<Series>

Called to merge all the partitioned results in a final aggregate.

Implementors§