nan_aware_weighted_mean#
- openstef_core.utils.pandas.nan_aware_weighted_mean(values, weights)[source]#
Weighted mean that redistributes NaN values’ weights proportionally.
For each row, weights corresponding to NaN values are zeroed out and the remaining weights are used to compute the weighted sum, normalized by their total. If all values in a row are NaN, the result is 0.
- Parameters:
values – DataFrame of values (may contain NaN).
weights – DataFrame of non-negative weights, aligned with values.
- Returns:
Series with the weighted mean for each row.