Finding median and mode from "summed" columns in pandas dataframe

Viewed 38

I have a pandas dataframe df as shown below. Count is the number of items of ItemPrice.

ItemPrice | Count
----------+---------
2         | 3
3         | 5
4         | 10
5         | 4

I can find the mean of Count by sum(df["ItemName"] * df["Count"]) / sum(df["Count"]). But can I get the median and mode of Count as well?

ETA: Changed the example dataframe as the column ItemName should be ItemPrice instead. Count is the number of items of ItemPrice.

0 Answers
Related