qis.series_nansum_weighted

qis.series_nansum_weighted(data, weights)[source]

weighted sum of finite entries: sum_i w_i x_i, with non-finite terms skipped.

Weights are not renormalised, so this is a weighted sum and not a weighted mean; pass weights summing to one when a mean is wanted. A term is skipped when either its value or its weight is non-finite, so a missing observation contributes nothing rather than propagating NaN into the total.

Parameters:
  • data (Series) – values, indexed to align with weights

  • weights (Series) – weights, in the same order as data

Returns:

the weighted sum

Raises:

ValueError – if either argument is not a pd.Series

Return type:

float