I was hoping that it was possible to format the index (column) directly in connection with output to HTML with the to_html() in the Pandas DataFrame?
Something like:
df = DataFrame([[1, 2]], index=['a'], columns=['A', 'B'])
print(df.to_html(formatters={
'index': lambda elem: '<a href="example.com/{}">{}</a>'.format(elem, elem)}, escape=False))
This does not work. I do not get a link.
I suppose I would need to do something like
dfc = df.copy()
dfc.index = ['<a href="example.com/{}">{}</a>'.format(i, i) for i in df.index]
print(dfc.to_html(escape=False))