API: Add Styler.where · Issue #16255 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
Instead of
df.style.applymap(lambda val: 'color: %s' % 'red' if val < 0 else 'black')
It would be
df.style.where(lambda val: val < 0, 'color: red', 'color: black')