擅长:python、mysql、java
<p>让我们试试<code>apply</code>和<code>axis=1</code>:</p>
<pre><code>df.style.apply(lambda x: ['color:red' if x['In / Out']=='Out'
else 'color:green']*len(x), axis=1)
</code></pre>
<p>输出:</p>
<p><a href="https://i.stack.imgur.com/6YwqV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YwqV.png" alt="df.style.apply(lambda x: ['color:red' if x['In / Out']=='Out' else 'color:green']*len(x), axis=1)"/></a></p>