Merge rows of a dataframe in pandas based on a column

pandas, python

Solution

If you want to keep your sitename and name in your dataframe, you can do :

df = dataframe.groupby(['date', 'sitename', 'name']).sum()

EDIT : See @DSM's comment to reset the indexes and have a non indexed dataframe.

Problem

I am new to pandas. I have a dataframe that looks like this ``` sitename name date count 0 chess.com Autobiographer 2012-05-01 2 1 chess.com Autobiographer 2012-05-05 1 2 chess.com Autobiographer 2012-05-15 1 3 chess.com Autobiographer 2012-05-01 1 4 chess.com Autobiographer 2012-05-15 1 5 chess.com Autobiographer 2012-05-01 1 ``` How to merge the rows based on date and sum up the count for the same date. Like in sql ``` select sitename, name, date count(*) from table group by date ```

Original source