0

I need to get max after agg('max') but I'm not succeeding. my question on the data is: For each defender_king print the battle in which he had the biggest defender_size

what i tried is:

battles.groupby(by=['defender_king','battle_number'])['defender_size'].agg('max')

and also:

battles.groupby(by=['defender_king','battle_number'])['defender_size'].max()

from this question: Get the row(s) which have the max value in groups using groupby-but it doesn't solve it-because of multiple selection of columns..(try it yourself and see)

but i get:

defender_king             battle_number
Balon/Euron Greyjoy       11                 900.0
                          13                   NaN
                          29                   NaN
                          31                 200.0
Joffrey/Tommen Baratheon  4                20000.0
                          5                 6000.0
                          6                12625.0
.
.
.

when what i want is:

defender_king             battle_number
    Balon/Euron Greyjoy       11                 900.0
    Joffrey/Tommen Baratheon  4                20000.0
.

only the max values from between all the values I get. Like max of max by column.

0 Answers0