Add CSS to the Jupyter Notebook using Pandas
In Jupyter Notebook, when we print the output table of our data, it shows a very basic table containing the data. But what if we want to customize this default style? In this article, we will see how we can add styles to our output data table.
This is how a default data table looks like in Jupyter Notebook:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Now let’s try to change the style. We can do it by the set_table_styles method of pandas module.
Now we need to pass the ‘selectors’ and ‘props’ as argument to this method, i.e. we need to select the CSS tags of the table (eg: th, td etc) and change the values of their properties (eg: background, font-color, font-family etc).
So, if we need to change the font-family of the text in the data section of the table, we can do it like this:
Let’s try to add more changes and see the output.
We can also hide the index column by