Python Forum
2 Different Sorts in a Dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 Different Sorts in a Dataframe
Hello everyone!

I have a dataframe with 2 columns (A,B) and 3 rows.


1 X
2 Y
3 Z

I am using this code right now

variable = df["A"].sort_values(ascending=True).values[-1]
To assign the current highest value of A to my variable.

How would I make it so, when it assigns the highest value to "variable", that is only checks for X in column B instead of checking every row?

So I would like the code to instead assign 1 to variable, since the highest number for X is 1

Any ideas?
Got it right here, if anyone is interested in also learning!


Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a lambda function that sorts dictionary GJG 1 354 Mar-09-2021, 06:44 PM
Last Post: buran
  Python sorts all arrays instead of one. Alex009988 2 628 Sep-02-2019, 02:31 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020