I want to sum up rows in a dataframe which have the same row key.
The purpose will be to shrink the data set size down.
For example if the data frame looks like this.
Fruit Count
Apple 10
Pear 20
Apple 5
Banana 7
Banana 12
Pear 8
Apple 10
I want the final dataframe to look like this.
Fruit Count
Apple 25
Pear 28
Banana 19
I am using Python's pandas, numpy, matplotlib and other data analysis packages. Is there a way to do this in python using functions in these packages?
Here is the code to create the example dataframe.
df = pd.DataFrame([["Apple", 10], ["Pear", 20], ["Apple", 5], ["Banana", 7], ["Banana", 12], ["Pear", 8], ["Apple", 10]], columns=["Fruit", "Count"])