Reputation: 45
I have a dataframe, these are the first lines:
(idx1) AMAZONAS 15
(idx2) AMAZONAS 2
(idx3) ANTIOQUIA 881
(idx4) ANTIOQUIA 696
(idx5) ANTIOQUIA 632
(idx6) ANTIOQUIA 702
as you can see, there are some names that repeat, and I need to group all that names that are repeated and sum the values on the right. i've tried functions pd.apply, groupby, but it didn't work Idk why. Please help!!!!
Upvotes: 1
Views: 44
Reputation: 2621
If the dataframe df has columns like name and count, for, respectively, values AMAZONAS and 15, for example, you cand do:
df.groupby('name')['count'].sum()
Upvotes: 1