Skip to content Skip to sidebar Skip to footer

Python Pandas Dataframe Aggregate Groupby

I have pandas DataFrame with many rows and columns, only three rows shown here: date place number 2010 LON 10 2010 BER 20 2010 LON 5 2011 LON

Solution 1:

You can try:

df.groupby(['date','place']).agg(sum)

Or If you want to get exactely the data frame as in your example:

df.groupby(['date','place']).agg(sum).reset_index()

Post a Comment for "Python Pandas Dataframe Aggregate Groupby"