andrew fay
andrew fay

Reputation: 95

Applying multiple functions to pandas column

I am attempting to sort by the maximum value of a column such as:

    dfWinners = df_new_out['Margin'].apply[max().sort_values(ascending=False)]

But am unsure of how to use the apply function for multiple methods such as max and sort. I'm sure it's a very simple problem but I cannot for the life of me find it through searching on here. Thank you!

Upvotes: 0

Views: 232

Answers (1)

A.Kot
A.Kot

Reputation: 7903

It's not clear what you're trying to do by assigning to dfWinners

If you intend dfWinners to be a list of sorted maximum to minimum values as you've described above then you can use the native sorted() method of python.

dfWinners = sorted(df_new_out['Margin'])

Else, you can sort your dataframe in place

df_new_out.sort_values(by = ['Margin'], ascending=False, inplace=True)

Upvotes: 1

Related Questions