As of 1.10: what is best way hyperlinked text cells in dataframes

With the changes to st.dataframe in 1.10 and the switch to a new underlying library, what is now the best way to make text cells in a dataframe into clickable hyperlinks?

Wrt to hyperlinking text cells in dataframes, nothing has changed. Here’s an example that works in earlier versions and 1.10.0:

import streamlit as st
import pandas as pd

def hyperlink(url):
    return f'<a target="_blank" href="{url}">{url}</a>'

df = pd.DataFrame(columns=['page'])
df['page'] = ['https://www.google.com', 'https://www.youtube.com', 'https://www.facebook.com']
df['page'] = df['page'].apply(hyperlink)
df = df.to_html(escape=False)

st.write(df, unsafe_allow_html=True)

dataframe-hyperlink

1 Like