I am using streamlit and loading data that I would like to put into a table with more customization than is currently offered by st.dataframe and st.table.
Below I use the tabulate package to change my data (after manipulating it with pandas) into an html table. My data is large so not something that I would like to type out. This is shown below with random data.
I then would like to add to the basic html template that is produced with my data things like a custom header and a larger font and a height for the table, however I can't seem to find a way to access the html stored in test2. I can wrap things around it (shown below) but can't get into the which is stored in test2.
Any thoughts on how to add to a tabulated tables output html would be helpful
import tabulate as tb
import streamlit as st
import pandas as pd
import numpy as np
np.random.seed(42)
data = {
'A': np.random.rand(100),
'B': np.random.randint(1, 100, size=100),
'C': np.random.choice(['X', 'Y', 'Z'], size=100)
}
df = pd.DataFrame(data)
test2=tb.tabulate(data, tablefmt='html')
test3 = f'<div style="height: 150; overflow: auto">{test2}</div>'
st.markdown(test3, unsafe_allow_html=True)



tabulatehas aheadersparameter, and font/height can be changed by outputting custom CSS. Have you considered these options?CSSto format elements inHTML. Second:df.to_html()generates HTML with table without usingtabulate. Anddf.stylehas functions to format table beforeto_html().