【发布时间】:2016-10-12 11:22:54
【问题描述】:
在学习Pandas Style时,我得到了以下几点:
def highlight_max(s):
'''
highlight the maximum in a Series yellow.
'''
is_max = s == s.max()
return ['background-color: yellow' if v else '' for v in is_max]
我应该如何阅读is_max = s == s.max()?
【问题讨论】:
-
s == s.max()是一个表达式,其结果赋值给is_max。在大多数对象上,==产生一个布尔值(False或True)。如果s是一个系列,那么您将获得一个带有布尔值的系列。
标签: python python-2.7 pandas