arnaudmiribel / streamlit-extras

Discover, try, install and share Streamlit re-usable bits we call "extras"!
https://extras.streamlit.app
Apache License 2.0
737 stars 125 forks source link

✨ [IDEA] - Allow manual `key` for `dataframe_explorer` #195

Closed PGijsbers closed 11 months ago

PGijsbers commented 11 months ago

Description

I am using dataframe_explorer in multipage apps. For whatever reason, it seems that the filtering is not persistent across pages, even when providing the same dataframe. When I render the dataframe_explorer of the same dataframe in different pages (though from the same imported function call), the filters are gone when I switch pages. However, it does work when a key for the widget is provided (I tried by editing locally). The problem is that this is that this isn't possible out of the box.

Minimal code for the extra

Update `dataframe_explorer`:

@extra
def dataframe_explorer(df: pd.DataFrame, case: bool = True, key:str =None) -> pd.DataFrame:
    ...
    random_key_base = key or pd.util.hash_pandas_object(df)

Then call it like:

filtered_results = dataframe_explorer(df, case=False, key="persistent_dataframe")

from the different pages.

PGijsbers commented 11 months ago

Nevermind, I am sorry. The persistence does not seem to work. I am not sure why it seemed like it did a minute ago. Any help with this is appreciated. I can't change the issue to be a question, so I closed it instead.