Answers for "pandas weighted average groupby"

0

pandas weighted average groupby

(sales["Current_Price"] * sales["Quantity"]).sum() / sales["Quantity"].sum()
(sales["New_Product_Price"] * sales["Quantity"]).sum() / sales["Quantity"].sum()
Posted by: Guest on April-30-2021
0

pandas weighted average groupby

sales.groupby("Manager").apply(lambda x: np.average(x['New_Product_Price'], weights=x['Quantity']))
Posted by: Guest on April-30-2021

Code answers related to "pandas weighted average groupby"

Python Answers by Framework

Browse Popular Code Answers by Language