You work with DataFrame, so it sets the string to red, if at least one value is less than 0the string:
def color_negative_red(x):
c1 = 'background-color: red'
c2 = 'background-color: black'
df1 = pd.DataFrame(c2, index=x.index, columns=x.columns)
df1 = df1.where((x > 0).all(axis=1), c1)
return df1
df.style.apply(color_negative_red, axis=None)
source
share