Create grouped dataframe by properties of a given column?

Would it have to do with how sortperm handles the by kwarg? If it’s handled the same way you mentioned here.

Then could sortperm be computing f(data) multiple times to sort the data whereas with

f.(data) is calculated just once?