pandas: groupby and variable weights
问题 I have a dataset with weights for each observation and I want to prepare weighted summaries using groupby but am rusty as to how to best do this. I think it implies a custom aggregation function. My issue is how to properly deal with not item-wise data, but group-wise data. Perhaps it means that it is best to do this in steps rather than in one go. In pseudo-code, I am looking for #first, calculate weighted value for each row: weighted jobs = weight * jobs #then, for each city, sum these