-
-
Notifications
You must be signed in to change notification settings - Fork 976
Open
Description
I think this fixes the problem of missing values. Is it correct way of handling missing values ?
def wavg(group, avg_name, weight_name):
import numpy as np
group=group[np.isfinite(group[avg_name])] # ignores missing values
d = group[avg_name]
w = group[weight_name]
try:
return (d * w).sum() / w.sum()
except ZeroDivisionError:
return d.mean()
Metadata
Metadata
Assignees
Labels
No labels