I have the next problem: I have a dataframe in pandas with an attribute 'features' and another attribute 'VOTES'. 'VOTES' is numeric, and 'features' is a string which is repeated in the dataframe. I want to group according to features and sum the values of VOTES, in order to get the next result:
Dataframe initially:
+----------+---------+
| features | VOTES |
+----------+---------+
| A | 4 |
+----------+---------+
| V | 3 |
+----------+---------+
| A | 2 |
+----------+---------+
| C | 9 |
+----------+---------+
I did the following but I got NaN values on VOTES column.
dataframe_clusters['VOTES'] = dataframe_clusters.groupby('features')['VOTES'].sum()
I want to get the next result:
+----------+---------+
| features | VOTES |
+----------+---------+
| A | 6 |
+----------+---------+
| V | 3 |
+----------+---------+
| C | 9 |
+----------+---------+