Css 使用style.apply时隐藏列

Css 使用style.apply时隐藏列,css,pandas,Css,Pandas,我正在使用df.style.applymap渲染数据帧。我选择了样式而不是html,因为我需要基于一些列值应用css。挑战在于我想从显示中排除其中一列。因此,使用以下代码: html = df.style.applymap(color_cell, subset=['columnName']).render() with open('output.html', 'w') as f: f.write(html) 是否有方法可以排除/隐藏设置其他列样式所需的列 在呈现HTML时,可以删除要隐

我正在使用df.style.applymap渲染数据帧。我选择了样式而不是html,因为我需要基于一些列值应用css。挑战在于我想从显示中排除其中一列。因此,使用以下代码:

html = df.style.applymap(color_cell, subset=['columnName']).render()
with open('output.html', 'w') as f:
    f.write(html)

是否有方法可以排除/隐藏设置其他列样式所需的列

在呈现HTML时,可以删除要隐藏的列:

cols_2_hide = ['col1','col2']
df.drop(cols_2_hide, axis=1).style.applymap(color_cell, subset=['columnName']).render()

可以在呈现HTML时删除要隐藏的列:

cols_2_hide = ['col1','col2']
df.drop(cols_2_hide, axis=1).style.applymap(color_cell, subset=['columnName']).render()

如果需要隐藏在函数“颜色”单元格中的列,可以使用styler的“隐藏列”功能

df.style.hide_columns([hide_cols_list]).applymap(color_cell, subset=['columnname' + hide_cols_list]).render()

如果需要隐藏在函数“颜色”单元格中的列,可以使用styler的“隐藏列”功能

df.style.hide_columns([hide_cols_list]).applymap(color_cell, subset=['columnname' + hide_cols_list]).render()

为什么不简单:df.drop['col1','col2'],axis=1.style.applymapcolor\u单元格,subset=['columnName']。render?Ty Max!这正是我所需要的。为什么不简单:df.drop['col1','col2',axis=1.style.applymapcolor\u cell,subset=['columnName']。render?Ty Max!这正是我所需要的。