Dynamic row filtering via ".hide" from pandas styling?

Hi all,

First off- I love streamlit, it is great :slight_smile:

I’m wondering if there are any plans to extend support for pandas styling in st.dataframe, particularly for the β€˜.hide’ functionality? It would be useful for me because it would allow for dynamic filtering of dataframes without the extra latency needed to re-style the whole dataframe. You can do that right now for columns with column_config, but as far as I know no such thing is possible for rows.

By the way, for me .hide has been just removing formatting from the rows that are supposed to be hidden. For reference when I run the following with streamlit 1.32.2:

import streamlit as st
import pandas as pd
import copy

data = pd.DataFrame({β€˜X’ : [1,2,3]
, β€˜Y’ : [4,5,6]
, β€˜Z’ : [7,8,9]}
, index = [β€˜A’,β€˜B’,β€˜C’])

data_without_hide = data.style.background_gradient(axis = None)

data_with_hide = data.style.background_gradient(axis = None).hide(subset = [β€˜A’], axis = 0)

c1, c2 = st.columns(2)

with c1:

st.write('Table without hide:')

st.write('Table with hide:')

with c2:

st.write('Dataframe without hide:')

st.write('Dataframe with hide:')

The result I get is

The same dataframe displays correctly in a jupyter notebook, with the first row hidden. I don’t know if this qualifies as a bug because it’s established that not all pandas styling is supported in streamlit, but it is a bit strange


1 Like

I was going to point you to comment on a related GitHub issue, but I see you already found it. :grin:

1 Like

haha yup! I’ll also link this topic from there

1 Like