This code works correctly and creates the clickable URL. But I will like to make the "name" column clickable and hide url. Is it possible?
data = [dict(name='Google', url='http://www.google.com'),
dict(name='Stackoverflow', url='http://stackoverflow.com')]
df = pd.DataFrame(data)
def make_clickable(val):
return '<a href="{}">{}</a>'.format(val, val)
df.style.format({'url': make_clickable})
df['nameurl'] = df['name'] + '#' + df['url']
def make_clickable_both(val):
name, url = val.split('#')
return f'<a href="{url}">{name}</a>'
df.reset_index().style.format({'nameurl': make_clickable_both})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With