Open harsh47 opened 5 years ago
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()
I think this fixes the problem of missing values. Is it correct way of handling missing values ?