python - Adding rows that have the same column value in a pandas dataframe -


i have pandas dataframe dates , hours columns. want add hours of same dates. example make this:

7-1-2016 | 4 7-1-2016 | 2 4-1-2016 | 5 

into this:

7-1-2016 | 6 4-1-2016 | 5 

is there quick way on big files?

here groupby can used provide desired output.

dataframe.groupby(by=none, axis=0, level=none, as_index=true, sort=true, group_keys=true, squeeze=false) group series using mapper (dict or key function, apply given function group, return result series) or series of columns.

try: df.groupby('date')['hours'].sum()


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -