highlighting maximum value dataframe - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: highlighting maximum value dataframe (/thread-15449.html) |
highlighting maximum value dataframe - PolskaYBZ - Jan-17-2019 Hello, I am reading through a book about data analysis where I got stuck with an excercice in which I need to highlight the maximum value of each column in a pandas Dataframe. After I removed all the unneccesary data in a Dataframe, I need to perform the last 3 steps ; 1. Use the idxmax method to find the index label of the maximum value for each column. max_cols = college_n2.idxmax() max_cols Length: 18, dtype: object2. Call the unique method afterwards on the max_cols Series, unique_max_cols = max_cols.unique() unique_max_cols[:5] 3. Afterwards, the values of unique_max_cols will be passed in the dataframe to select and highlight the maximum value.college_n2.loc[unique_max_cols].style.highlight_max()I understand the first step, but I do not fully understand why in step 2 I need to select only the unique values and how then anyway in step 3 they are able to select the maximum values. Some clarification would be much appreciated. Thank you. |