-1

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?

richardec
  • 14,202
  • 6
  • 23
  • 49
hakoshi
  • 1
  • 1
  • Does [`.groupby().sum()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.sum.html?highlight=sum) solve your problem? – Rawson May 14 '22 at 15:28

0 Answers0