Skip to content
Advertisement

Why does Excel styling not work in Pandas?

JavaScript

I tried to apply highlight_max to columns

Advertisement

Answer

So I’m going to assume you want to apply your style change to your dataframe in python the way it is designed to be implemented and display the color modifications when you print your dataframe in console. The issue is (I’m assuming) that you are not using the IDE Jupyter Notebook(or any other web based IDE), where it is designed to be utilized. See comparison below.

Source: Pandas Styling Documentation

The style object is rendered in html where a web based IDE like Jupyter Notebook can read in and display the modifications.

This is running a simplification taken from documentation on Spyder IDE. Notice the output is a style object. When rendered you can see in the second output the html/css that Spyder IDE can’t interpret.

JavaScript

The second example is running the exact same simplification on the web based IDE Jupyter Notebooks. Notice the resulting output from s displays the modified styling desired.

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement