Issue
I had no problem with the alignment in the old version but when I upgraded to the new version I saw this happen. I tried the following 3 different approach below the dataframe but none of them fixes the problem. Is there any way to work around it?
#Sets df size with width 1000 and height 300, but width has a limited range
st.dataframe(df, 1000, 300)
st.dataframe(df, use_container_width=True)
st.write(df, use_container_width=True)
Solution
I ask this question for a while now but yet didn't get any response until I figured a way to handle my problem.
I used Streamlit AgGrid component to fix my problem. AgGrid()
by default will center the dataframe, it also has other awesome features of handling data frames much better than st.dataframe()
and it is pretty simple and clean. I could even choose to color the data frame to my liking which I found pretty cool and interactive.
In case you face similar problem and want to take this approach I will recommend you visit Streamlit AgGrid component to know the inside of the component and how it is implemented.
from st_aggrid import AgGrid
AgGrid(df)
OUTPUT:
Answered By - Jamiu S.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.