arche
arche copied to clipboard
Clickable urls in dataframe views
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.
Workaround: classic notebook UI.
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
.