Apply 2 styles

How do I apply 2 styles to a dataframe?
t = st.empty()
t.dataframe(df.style.apply(highlight_cells, axis=None) , width=1024, height=768 )

works and so does

t = st.empty()
t.dataframe(df.style.format(subset=[‘open’], formatter="{:.2f}"))

How do I apply both? This doesnt work:
t = st.empty()
df.style.apply(highlight_cells, axis=None)
t.dataframe(df.style.format(subset=[‘open’], formatter="{:.2f}"))

neither does:
t = st.empty()
df.style.format(subset=[‘open’], formatter="{:.2f}")
t.dataframe(df.style.apply(highlight_cells, axis=None) )

or
t = st.empty()
df.style.format(subset=[‘open’], formatter="{:.2f}")
df.style.apply(highlight_cells, axis=None)
t.dataframe(df )

What is this style object? Why doe you need to run it inside st.dataframe() ? How can you then run multiple styles?

It’s a pandas question (pandas.io.formats.style), not streamlit

You can simply chain the styles, e.g:
df_styled = (df.style.
format({‘col_1’: ‘{:.2f}’, ‘col_2’: ‘{:.1f}’}).
applymap(color_df, subset=[‘col_1’]))

st.dataframe(df_styled)

1 Like

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