Im trying to add an up and down arrow to a pandas data frame with to_html for an email report.
I'm using a lambda function to input an up and down arrow onto column values in my data frame, I know the image html works ok becasue I can put it in the body of the email and it works fine but when I use this function and the pandas formatter it outputs like in the below image (ps. i know the CID is different to whats in my function, I was just tesing something)
Any one have any idea why? Or anyone have a better way to do it?
call:
worst_20_accounts.to_html(index=False,formatters={'Last Run Rank Difference': lambda x: check_html_val_for_arrow(x)}))
function:
def check_html_val_for_arrow(x):
try:
if x > 0:
return str(x) + ' <img src="cid:image7">'
elif x < 0:
return str(x) + ' <img src="cid:image8">'
else:
return str(x)
except:
return str(x)

