2 Different Sorts in a Dataframe - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: 2 Different Sorts in a Dataframe (/thread-33307.html) |
2 Different Sorts in a Dataframe - stylingpat - Apr-14-2021 Hello everyone! I have a dataframe with 2 columns (A,B) and 3 rows. A B 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? RE: 2 Different Sorts in a Dataframe - stylingpat - Apr-14-2021 Got it right here, if anyone is interested in also learning! https://datatofish.com/select-rows-pandas-dataframe/ |