message_ix_models.tools.iea.eei.wavg
- message_ix_models.tools.iea.eei.wavg(measure: str, df: DataFrame, weight_data: DataFrame) DataFrame [source]
Perform masked & weighted average for measure in df, using weight_data.
Todo
Replace this with usage of genno; add tests.
WAVG_MAP
is used to select a data from weight_data appropriate for weighting measure: either “population”, “vehicle stock” or “vehicle-kilometres*. If the measure to be used for weights is all NaNs, then “population” is used as a fallback as weight.The weighted average is performed by grouping df on the “region”, “year”, and “Mode/vehicle type” dimensions, i.e. the values returned are averages weighted within these groups.
- Parameters:
measure (
str
) – Name of measure contained in df.df (
pandas.DataFrame
) – Data to be aggregated.weight_data (
pandas.DataFrame.
) – Data source for weights.
- Return type: