arche icon indicating copy to clipboard operation
arche copied to clipboard

Clickable urls in dataframe views

Open manycoding opened this issue 5 years ago • 2 comments

It will be really convenient to have clickable urls, as opposing to manually copying them and opening a page each time. It will save time. As far as I remember pandas has https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.io.formats.style.Styler.html#pandas.io.formats.style.Styler, so maybe it can be used to achieve it.

manycoding avatar Apr 30 '19 15:04 manycoding

Workaround: classic notebook UI.

manycoding avatar Jul 06 '19 16:07 manycoding

This snippet do the job, but it doesn't modify the df in-place, AFAIK (df.style returns a new Styler every time you call it).

def make_clickable(val):
    if isinstance(val, str) and re.search('^https?://', val):
        return f'<a target="_blank" href="{val}">{val}</a>'
    else:
        return val

df.style.format(make_clickable)

Maybe there is a way to create a default Styler.

tcurvelo avatar Jul 22 '19 00:07 tcurvelo