Data Frame Column and Row İndex Color Changing Problem in Streamlit

Hello, Is there a way to change the data frame row (index) and column name text color? Additionally, how do I change the width of the data frame?

df_count=df["ACIKLAMA"].value_counts(ascending=False).to_frame()
    df_count.columns=["count_of_purchase/campaign"]
    max_purchasing=df_count.iloc[0:1]
    max_purchasing.rename(columns = {'count_of_purchase/campaign':'max_count_of_purchase/campaign'}, inplace = True)
    #print("max number of purchasing/campaign frequency:\n\n",max_purchasing)
    
    
    
# only valid for values
 st.markdown('<style>div[class="css-o1jpvw e19lei0e1"] { color: black; background:white;font-weight: normal; } .data:hover{ background:cyan;)}</style>', unsafe_allow_html=True) 


# this is not working
 st.dataframe(max_purchasing,height=1000,width=390)

Hi @murat_tasci,

Thanks for posting!

For the width/height, there is an open issue with setting dataframe width – I’ll bring this up to our team and see if we can get an estimate on when it will be resolved. In the meantime, you can use st._legacy_dataframe or st.table to avoid this bug.

For the styling part of your question, heck out this example from our documentation:

You can also pass a Pandas Styler object to change the style of the rendered DataFrame:

df = pd.DataFrame(
    np.random.randn(10, 20),
    columns=('col %d' % i for i in range(20)))

st.dataframe(df.style.highlight_max(axis=0))

Caroline :balloon:

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