Reputation: 1325
I want to fancy my pandas dataframe and prep it for an html rendering. pandas styler is a wonder in this regard, if not for this bit (http://pandas.pydata.org/pandas-docs/stable/style.html) where it says in the limitations section:
You can only style the values, not the index or columns You can only apply styles, you can't insert new HTML entities
So no official solution but, I was wondering whether a workaround was possible to not see the index. I was thinking about 3 solutions:
set my index to ' ' but indexes have to be unique so we go for the second
find some way to eliminate the data related to the index inside the string ready for rendering. couldn't manage to find a valid procedure yet
find a way to apply a css condition for which the index is of the color of the background so, though the space will be occupied, it won't be seen. could not find a way to implement it.
Any better ideas or ways to successfully do any of the above? Please bear in mind that I just want something that works. It need not be elegant or scalable.
Upvotes: 1
Views: 258
Reputation: 81
You can try to not display the index column (or style it) like that:
df.reset_index().style.set_table_styles(
[{'selector': '.row_heading, .blank',
'props': [('display', 'none')]}]
Upvotes: 1