# Links in st.dataframe with styler

**URL:** <https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422>\
**Category:** Using Streamlit\
**Created:** [February 2, 2024, 7:54pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422 "2024-02-02T19:54:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![msquaredds](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/msquaredds/32/54045_2.png) [@msquaredds](https://discuss.streamlit.io/u/msquaredds)\
**Post date:** [February 2, 2024, 7:54pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/1 "2024-02-02T19:54:14Z")

</div>

I just started trying to use the new functionality of including links in a streamlit dataframe ([st.column\_config.LinkColumn - Streamlit Docs](https://docs.streamlit.io/library/api-reference/data/st.column_config/st.column_config.linkcolumn)).

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.

---

<div class="post-metadata">

**Author:** ![dataprofessor](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/dataprofessor/32/44163_2.png) [@dataprofessor](https://discuss.streamlit.io/u/dataprofessor)\
**Post date:** [February 3, 2024, 7:48am UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/2 "2024-02-03T07:48:00Z")

</div>

Hi @msquaredds

It seems that pandas styler may be used with `st.table` and may conflict with column\_config if used on `st.dataframe`.

Please see the following relevant forum posts:

> [@Using Pandas Styler with column\_config](https://discuss.streamlit.io/t/using-pandas-styler-with-column-config/52209):
>
> Hi all - ran into my first Streamlit issue I haven’t been able to resolve from the forums. Summary Using column\_config in conjunction with a Pandas styler object doesn’t appear to work. Steps to reproduce According to the docs, I can pass a pandas styler object to st.dataframe. This works. df = pd.DataFrame({ 'cost': [25.99, 97.45, 64.32, 14.78], 'grams': [101.89, 20.924, 50.12, 40.015] }) st.write(df) st.dataframe(df.style.highlight\_max(axis=0)) However, passing a s…

> [@Pandas styler with custom style](https://discuss.streamlit.io/t/pandas-styler-with-custom-style/37039):
>
> Hello, I want to show below dataframe styler using st.dataframe but it is not showing the custom style as per given in make\_bar\_style, Your inputs will be valuable: import pandas as pd import streamlit as st # example multi-index dataframe data = {'level\_0': [1, 2, 3], 'level\_1': ['A', 'B', 'C'], '01/23/2023': ['20%', '30%', '40%'], '01/24/2023': ['10%', '20%', '30%'], '01/25/2023': ['15%', '25%', '35%'], '01/26/2023': ['5%', '10%', '15%'], '01/…

---

<div class="post-metadata">

**Author:** ![sahirmaharaj](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/sahirmaharaj/32/54744_2.png) [@sahirmaharaj](https://discuss.streamlit.io/u/sahirmaharaj)\
**Post date:** [February 3, 2024, 4:50pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/3 "2024-02-03T16:50:25Z")

</div>

Hello @msquaredds,

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`.

```auto
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.

Kind Regards,  
Sahir

P.S. Lets connect on [LinkedIn](https://www.linkedin.com/in/sahir-maharaj/)!

---

<div class="post-metadata">

**Author:** ![msquaredds](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/msquaredds/32/54045_2.png) [@msquaredds](https://discuss.streamlit.io/u/msquaredds)\
**Post date:** [February 5, 2024, 7:12pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/4 "2024-02-05T19:12:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![msquaredds](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/msquaredds/32/54045_2.png) [@msquaredds](https://discuss.streamlit.io/u/msquaredds)\
**Post date:** [February 6, 2024, 1:01pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/5 "2024-02-06T13:01:44Z")

</div>

In case anyone else finds this, the link to a pre-existing issue on GitHub is here:

[https://github.com/streamlit/streamlit/issues/7977](https://github.com/streamlit/streamlit/issues/7977)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [February 8, 2024, 1:01pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/6 "2024-02-08T13:01:59Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![dataprofessor](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/dataprofessor/32/44163_2.png) [@dataprofessor](https://discuss.streamlit.io/u/dataprofessor)\
**Post date:** [February 10, 2024, 2:55pm UTC](https://discuss.streamlit.io/t/links-in-st-dataframe-with-styler/61422/7 "2024-02-10T14:55:28Z")

</div>

Great idea and implementation @sahirmaharaj
