Pandas Styler. How to ignore index column from rendered HTML

I am trying to use a string created by rendering a stylist in an email. It seems very difficult to get this to ignore the dataframe index.

table_styles = [dict(selector="tbody tr th", props=[("display", "none")]),
st=df.style.set_table_styles(table_styles)
st.render()

I was able to customize how CSS customization works without rendering, but it works differently on different devices based on the level of CSS support.
Isn't there a way to make the index payload just go away?

+4
source share
1 answer

, , , , ( ). , -, .

html.render().split('\n'), , ( resent_index).

, , CSS .

# define the style related to first column and index here
# first-element : when index =True, 
# second element: default index of the table generated by the Style
styles = [ 
  dict(selector = ".col0", props = [('display', 'none')]), 
  dict(selector = "th:first-child", props = [('display', 'none')])
 ]

 # set the table styles here
 table.set_table_styles(styles)
0

Source: https://habr.com/ru/post/1623703/


All Articles