python - 如何将熊猫数据框中的边框添加到 html 表格行标题?
问题描述
Pandas 样式选项让我格式化数据,但我想为列标题添加边框,即第 0 行。
htmlFooterOutdatedList = dfServerOutdated[['System Name','IP Address','Last Communication','DAT (VSE)','OS Type','Status']].style.hide_index().set_properties(**{'font-size': '10pt','background-color': '#edeeef','border-color': 'black','border-style' :'solid' ,'border-width': '1px','border-collapse':'collapse', 'padding': '5px'}).applymap(datversion,subset = 'DAT (VSE)').applymap(LTSCDate,subset = 'Last Communication').background_gradient(cmap='PuBu', low=0, high=0, axis=0, subset='DAT (VSE)', text_color_threshold=0.458).set_table_styles([{'selector': 'th', 'props': [('font-size', '12pt')]}]).set_properties(subset=['Last Communication'], **{'width': '180px'}).set_properties(subset=['System Name'], **{'width': '30px'}).set_properties(subset=['Status'], **{'width': '90px'}).render()
我可以为列标题添加边框吗?
解决方案
在您的(诚然很长的)代码行中,您已经拥有:
.set_table_styles([{'selector': 'th', 'props': [('font-size', '12pt')]}])
您可以通过常见的 CSS 属性进行扩展,例如:
.set_table_styles([{'selector': 'th', 'props': [('font-size', '12pt'),('border-style','solid'),('border-width','1px')]}])
推荐阅读
- c# - 打开文件时在 NPOI 中抛出异常,但仅在发布模式下
- php - 使用 WC Vendors Pro 插件从 Woocommerce 更改 CSV 导出数据
- python - 如何使用python从csv文件创建饼图
- jquery - 分离和附加的文本区域丢失鼠标事件
- f# - 如何在 F# 中创建可为空的列表?
- batch-file - 使用 Findstr 批量查找具有非 ASCII 字符的字符串
- cv2 - 为什么 cv2.rectangle() 不支持浮点值?
- python - 删除双重文件内容
- php - 如何使用表单、输入和 php 更新一些占位符文本?
- javascript - 如何将模板文字的结果保存到对象中?