weighted averae multiple columns code example
Example: weighted averae multiple columns
In [11]: g.apply(lambda x: pd.Series(np.average(x[["var1", "var2"]], weights=x["weights"], axis=0), ["var1", "var2"]))
Out[11]:
var1 var2
category
a 38.250000 34.000000
b 23.285714 6.428571