在学习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()将计算为 bool 值(由于变量之间的==)。下一步是将该值存储在is_max中。

关于python - is_max = s == s.max()|我应该怎么读?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39997334/

10-09 08:48
查看更多