aggregate_mean_or_first function

Aggregate mean or first