Hi all,
I’m trying to highlight all negative string values on the table below but I’m getting an error that i’m sure is because of the string formatting. Any ideas how I can modify the code to highlight the negative strings on the table?
Thanks!
def in_statements(val):
for statement in df2['Daily_Returns_Pct']:
if statement in val:
color = 'red'
if val < -1 : color = 'red'
break
return 'background-color: %s' % color
df2['Daily_Returns_Pct'] = df2.style.applymap(in_statements)
~/miniconda3/envs/Jlab/lib/python3.7/site-packages/ipykernel/jsonutil.py in json_clean(obj)
195
196 # we don't understand it, it's probably an unserializable object
--> 197 raise ValueError("Can't clean for JSON: %r" % obj)
ValueError: Can't clean for JSON: <pandas.io.formats.style.Styler object at 0x11c53cf98>