Add CSS to the Jupyter Notebook using Pandas
import pandas as pd
df = pd.DataFrame({'A':[1, 2, 3, 4, 5, 6, 7, 8],
'B':[1, 2, 3, 4, 5, 6, 7, 8],
'C':[1, 2, 3, 4, 5, 6, 7, 8],
'D':[1, 2, 3, 4, 5, 6, 7, 8]})
df.head()

df.style.set_table_styles()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:
df.style.set_table_styles(
[{'selector': 'td',
'props': [('font-family', 'Sans-serif')]},
])
df = pd.DataFrame({'A':[1, 2, 3, 4, 5, 6, 7, 8],
'B':[1, 2, 3, 4, 5, 6, 7, 8],
'C':[1, 2, 3, 4, 5, 6, 7, 8],
'D':[1, 2, 3, 4, 5, 6, 7, 8],
'E':[1, 2, 3, 4, 5, 6, 7, 8]})
df.style.set_table_styles(
[
{'selector': 'th',
'props': [('background', '# 606060'),
('color', 'white'), ]},
{'selector': 'td',
'props': [('color', 'blue')]},
])

hide_index()
method:
df.style.set_table_styles(
[
{'selector': 'th',
'props': [('background', '# 606060'),
('color', 'yellow'), ]},
{'selector': 'td',
'props': [('color', 'red')]},
]
).hide_index()
