Pandas Hiding A Column, To Stay In Df, But Not Displayed In Html Table
I have +-300 lines of code to give me a specific df table.. this table needs to be displayed in html. Everything is set up and working perfectly. The only problem is, that I have a
Solution 1:
You can create custom css styles. Here are added borders and hidden column col0
by Styler.set_table_styles
:
css = [
{
'props': [
('border-collapse', 'collapse')]
},
{
'selector': 'th',
'props': [
('border-color', 'black'),
('border-style ', 'solid'),
('border-width','1px')]
},
{
'selector': 'td',
'props': [
('border-color', 'black'),
('border-style ', 'solid'),
('border-width','1px')]
},
{'selector': '.col0',
'props': [('display', 'none')]}]
html = df.style.set_table_styles(css).render()
EDIT:
If want printing DataFrame without col1
then is possible use DataFrame.drop
this column or select only columns for printing:
df_print = df.drop('col1', axis=1)
df_print = df[['col2', 'col3', 'col4']]
Post a Comment for "Pandas Hiding A Column, To Stay In Df, But Not Displayed In Html Table"