Pandas样式

1、pandas 内置样式

空值高亮 highlight_null


最大最小值高亮



背景渐变 background_gradient

根据数值的大小背景颜色呈现梯度渐变,越深表示越大,越浅表示越小,类似于 Excel 的中的色阶样式。



条形图 bar



2、pandas 格式显示

我们在最终输出数据查看时,需要对数据进行相应的格式化,常见的如加货币符号、加百分号、增加千分位等,目的是让计数更加场景化,明确列表一定的业务意义。

Styler.format 是专门用来处理格式的方法。

常用方法

综合运用

3、样式高级操作


表格CSS样式


给所有的行(tr 标签)的 hover 方法给一个黄色背景

应用函数

样式调用函数的方法有:

  • Styler.applymap: 所有元素
  • Styler.apply: 列/行/表
  • Styler.pipe: 管道方法,Styler 对象

4、参考文献

《深入浅出Pandas》

posted @ 2022-07-23 23:18  朝南烟  阅读(66)  评论(0编辑  收藏  举报
body { color: #000; background-color: #e6e6e6; font-family: "Helvetica Neue",Helvetica,Verdana,Arial,sans-serif; font-size: 12px; min-height: 101%; background: url(https://images.cnblogs.com/cnblogs_com/caolanying/1841633/o_2009041…ly1geq8oc9owbj21hc0u0th5.jpg) fixed; } #home { margin: 0 auto; opacity: 0.8; width: 65%; min-width: 1080px; background-color: #fff; padding: 30px; margin-top: 50px; margin-bottom: 50px; box-shadow: 0 2px 6px rgba(100, 100, 100, 0.3); }