When I follow the given pattern, but use it on a pd.Styler object instead of a pd.DataFrame, the LinkColumn seems to just be ignored. Instead of displaying just the portion of text defined in the regex “(.*?)” and making it a hyperlink, I am seeing the full link text and it is just displaying as a string.
Is this expected behavior or is there something I am missing?
If this is expected, I would request allowing the links in a Styler - it helps immensely to have a stylized DataFrame since it helps with the user experience.
My Streamlit version is 1.31.0, I am running it through a private AWS server using python 3.10.12.
If you decide to manually embed links, you’d typically have to convert your DataFrame to HTML and then insert that HTML into st.markdown.
import streamlit as st
import pandas as pd
df = pd.DataFrame({
'Name': ['Item 1', 'Item 2'],
'URL': ['http://example.com/1', 'http://example.com/2']
})
df['Linked Name'] = df.apply(lambda x: f'<a href="{x["URL"]}">{x["Name"]}</a>', axis=1)
html = df.to_html(escape=False, index=False)
st.markdown(html, unsafe_allow_html=True)
This method directly embeds HTML links into the DataFrame, but it bypasses the pd.Styler and LinkColumn Streamlit functionality, limiting the approach to static displays.
Thanks both for the additional info and supplying other methods of getting the links to work
That being said, I’ll probably put in an issue on this in GitHub (or see if one is already there) - it seems like the ideal functionality would be to have links available in a first class way while using a styler object