is_max = s == s.max() | How should I read this?
<p>While studying <a href="http://pandas.pydata.org/pandas-docs/stable/style.html" rel="nofollow">Pandas Style</a>, I got to the following:</p>

<pre><code>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]
</code></pre>

<p>How should I read <code>is_max = s == s.max()</code>?</p>

<p>In pandas <code>s</code> is very often <code>Series</code> (column in <code>DataFrame</code>).</p>

<p>So you compare all values in <code>Series</code> with <code>max</code> value of <code>Series</code> and get boolean mask. Output is in <code>is_max</code>. And then set style <code>'background-color: yellow'</code> only to cell of table where is <code>True</code> value - where is max value.</p>

<p>Sample:</p>

<pre><code>s = pd.Series([1,2,3])
print (s)
0    1
1    2
2    3
dtype: int64

is_max = s == s.max()
print (is_max)
0    False
1    False
2     True
dtype: bool
</code></pre>

python python-2.7 pandas