Skip to content
Advertisement

Dash Bootstrap Components: Create Table with links from Pandas dataframe

EDIT: Please don’t invest time into an answer – I found the solution myself, but instead of deleting it I want to keep it for others in case they have the same problem. I cannot close it however, but no need to provide additional answers, thanks!

Title already says it all – I want to create a dbc table from a pandas Dataframe. However, it looks like the columns are not being parsed, neither with HTML nor with markdown syntax:

p = {}  
p["LinkColumn"] = f'<a href="{my_link}">Link</a>' # Does not work
p["LinkColumn"] = f'[link]({my_link})'            # Does not work either...

# Code is simplified, but the idea is to create pd.DataFrame then dbc Table:
dbc.Table.from_dataframe(pd.DataFrame(p))

Both variants simply print everything in plain text, meaning the link is displayed as text instead of linking to the page I want. Is there another way to do it? Maybe some option like parse_html=True?

Advertisement

Answer

Upon further investigation, I realized that the Dash html components are being parsed, including the link component:

p["LinkColumn"] = html.A("Link", href=my_link)
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement