Rendering Data Frames from an HTML code

Jupyter notebooks render pandas DataFrames in a nice format. Streamlit supports this too.

When I looked at the json code that creates .ipnyb files, I noticed that the dataframes are rendered using HTML code like this:

<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;

    .dataframe tbody tr th {
        vertical-align: top;

    .dataframe thead th {
        text-align: right;
<table border="1" class="dataframe">
    <tr style="text-align: right;">

When I pass this to st.markdown(unsafe_allow_html=True) it is being displayed as a static table. Is there any way to convert the output to Streamlit supported dataframe from this HTML code?

I specifically want to be able to render pandas DataFrames from their HTML code not using st.dataframe.

Maybe try

import pandas as pd
html_df = '''<div> ...  </div>'''
df = pd.read_html(html_df )

Nope, it did not work. It is returning a list with the text of the dataframe

Just read the docs, pd.read_html returns a list of data frames. So you just need to index the list to get your dataframe.