Trait polars::prelude::PhysicalAggregation
source · [−]pub trait PhysicalAggregation: Send + Sync {
fn aggregate(
&self,
df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Series>, PolarsError>;
fn evaluate_partitioned(
&self,
df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Vec<Series, Global>>, PolarsError> { ... }
fn evaluate_partitioned_final(
&self,
final_df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Series>, PolarsError> { ... }
}
Required methods
fn aggregate(
&self,
df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Series>, PolarsError>
fn aggregate(
&self,
df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Series>, PolarsError>
Should be called on the final aggregation node like sum, min, max, etc. When called on a tail, slice, sort, etc. it should return a list-array
Provided methods
fn evaluate_partitioned(
&self,
df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Vec<Series, Global>>, PolarsError>
fn evaluate_partitioned(
&self,
df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Vec<Series, Global>>, PolarsError>
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.
fn evaluate_partitioned_final(
&self,
final_df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Series>, PolarsError>
fn evaluate_partitioned_final(
&self,
final_df: &DataFrame,
groups: &GroupsProxy,
state: &ExecutionState
) -> Result<Option<Series>, PolarsError>
Called to merge all the partitioned results in a final aggregate.