Streamlit loading column data takes too much time

I use simple code snippet in streamlit which shows dataframe consisting of excel which i have. the problem is that it takes too much time to load data inside the filter column of streamlit area. in that filter area i make search on material name, but it takes even 30 seconds to load and show me the data which i am gonna select. How to solve it and make it fastest to select data?

The code is:

import streamlit as st
import pandas as pd

@st.cache
def load_data(nrows):
    df=pd.read_excel('materials.xlsx',nrows=nrows)
    return df

df=load_data(100000)

species = st.multiselect('SELECT THE MATERIAL', df['Name'])
new_df = df[(df['Name'].isin(species))]
st.write(new_df)

and to show how it is too slow selecting data, look at this: https://streamable.com/kjis2

1 Like

Hi @M11,
thanks for your question. You are applying the multiselect box on 100,000 items, right? The multiselect itself is not designed to handle so many items. I think it may make sense to have a different widget that is a speed optimized search box. This question keeps coming up, though. I will open a github issue for this.

Matteo

2 Likes
1 Like