How to create a table with clickable hyperlink in pandas & Jupyter Notebook

If you want to apply URL formatting only to a single column, you can use:

data = [dict(name="Google", url="http://www.google.com"),
        dict(name="Stackoverflow", url="http://stackoverflow.com")]
df = pd.DataFrame(data)

def make_clickable(val):
    # target _blank to open new window
    return '<a target="_blank" href="https://stackoverflow.com/questions/42263946/{}">{}</a>'.format(val, val)

df.style.format({'url': make_clickable})

(PS: Unfortunately, I didn’t have enough reputation to post this as a comment to @Abdou’s post)

Leave a Comment