'Apply function on pandas.DataFrame by group of values in a columns

I have a data frame object in pandas with columns (let's say) "group". There are 20 groups. I want to apply a function (sum) to multiple rows of the same groups So: The input columns can be:

index||group||values
(50x20= 1000 rows)

The output should be something like:

group||sum
(20 rows)

Edit: I got an answer here to group the rows by column values, but wonder is there any way more efficient How do I select rows from a DataFrame based on column values?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source