Working on a class assignment.
Our current dataset has information that looks like:
Item ID Item Name Price
0 108 Extraction, Quickblade Of Trembling Hands 3.53
1 143 Frenzied Scimitar 1.56
2 92 Final Critic 4.88
3 100 Blindscythe 3.27
4 131 Fury 1.44
We were asked to group by two values, which I've done.
item_df = popcolumns_df.groupby(["Item ID","Item Name"])
I'm having issues though, trying to append the groupby functions to this dataframe. For instance, when I run count, the count replaces the price. Attempt one just replaced all the data in the price column with the counts.
item_counts = item_df.count().reset_index()
Output:
Item ID Item Name Price
0 0 Splinter 4
1 1 Crucifer 3
2 2 Verdict 6
3 3 Phantomlight 6
4 4 Bloodlord's Fetish 5
Attempt 2 did the same:
item_counts = item_df.size().reset_index(name="Counts")
My desired output is:
Item ID Item Name Price Count Revenue
0 108 Extraction, Quickblade 3.53 12 42.36
1 143 Frenzied Scimitar 1.56 3 4.68
2 92 Final Critic 4.88 2 9.76
3 100 Blindscythe 3.27 1 3.27
4 131 Fury 1.44 5 7.20
I would likely just use a sum on the groups to get the revenue. I've been stumped on this for a couple of hours, so any help would be greatly appreciated!