I\'m calculating weighted average for some fields and with the help of suggestions here groupby weighted average and sum in pandas dataframe I wrote the following: