I want to collapse dataframe rows that match values for a given column but the rest of the columns have to be collapsed with different logic. Example:
City ColumnA ColumnB
Seattle 20 30
Seattle 30 20
Portland 25 25
Portland 10 40
I want to collapse by City and I want ColumnA to keep the lowest value and ColumnB to keep the mean value, for instance. The result should look like:
City ColumnA ColumnB
Seattle 20 25
Portland 10 32.5
This is just an example, in my real problem I want to apply a more complex logic rather than min() or mean().
What is the right, cleanest and simplest way of doing this? Thank you.