Skip to content Skip to sidebar Skip to footer

Pandas Group By Product Instead Of Sum Or Count

In python pandas, I want to group a dataframe by column and then take the product of the rows for each ID. Sum and count functions exist, but a product? df2 = pd.DataFrame({'X' :

Solution 1:

There is prod:

df.groupby('X').prod()

Post a Comment for "Pandas Group By Product Instead Of Sum Or Count"