如何根据非空列突出显示所有行-pandas
我有一个由大量数据组成的数据框。我要做的是在称为“类型”的列中查看所有值,如果它不是空的,请突出显示整个行。
这就是我现在要重点介绍的目前
def highlight_row(rows):
if not rows is None:
return ['background-color: blue'] * len(rows.values)
df.style.apply(highlight_row, axis=1)
正在尝试将其引入的,以在数据框架df
中突出显示,我将导出到CSV文件中以在Excel中查看。
I have a DataFrame that consists of a large sum of data. What I'm trying to do is to look through all values in a column called 'Type' and if it's not empty, highlight that entire row.
This is what I have right now for the highlighting
def highlight_row(rows):
if not rows is None:
return ['background-color: blue'] * len(rows.values)
df.style.apply(highlight_row, axis=1)
I'm trying to get this to highlight it in the data frame df
that I'm exporting to a CSV file to view in excel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论