Multiselect button crashes app

I’m building an application that allows users to request data and once a dataframe has been created for said request, the user can then select unique instances of filter_playlist and/or filter_artist for further filtering via a multiselect option. However, whenever the user reaches this step, the user can no longer filter the dataframe and is forced to reset the app.

Quick notes:

  • the requested dataframe is the input df
  • ready_button is in the sidebar and it is activated when valid user credentials and URLs are entered
  • I call from multiple files in this application (e.g. proj_analysis) but I don’t think that’s an issue
def alter_dataframe(df):
    
    if ready_button:
        
        with st.beta_expander("Interact with Data Frame", True):
            
            search_filter = st.radio(label='', options=['Filter','Search'])

            if search_filter == 'Filter':
                
                filter_cols = st.beta_columns((3,3,2))
                filter_playlist = filter_cols[0].multiselect('Playlist', options=np.sort(data['playlist'].unique()))
                filter_artist = filter_cols[1].multiselect('Artist', options=np.sort(data['artist'].unique()))
                filter_release = filter_cols[2].slider('Year Range',
                                                            min_value=df['artist_date'].min().year,
                                                            max_value=df['artist_date'].max().year,
                                                            value = (df['artist_date'].min().year, df['artist_date'].max().year),
                                                            step=1)
                
                submit = st.button(label='Filter')
                
                if submit:
                    return proj_analysis.analysis_filter_dataframe(df, filter_playlist, filter_artist, filter_release)

Has anyone experienced something like this before or would know how to troubleshoot this bug? Thanks!

1 Like

Hi @lou_nel, and welcome to the Streamlit forums! :raised_hands:

Have you tried rebooting your app and run it with a smaller dataframe?
Would it be possible to review the full code?

Best,
Charly

1 Like

Hey @Charly_Wargnier thanks for responding. My most recent files are uploaded to my repo:

  • proj_pipeline.py: gathers the data
  • proj_analysis.py: formats the DataFrames
  • proj_plot.py: generates the plots
  • proj_proj.py: puts it all together via Streamlit
1 Like

Thanks for these.
Did you try with smaller datasets/dataframes?

Best,
Charly

Yes - still no luck unfortunately

1 Like

Ok thank you.

Do you get any log trace with it, or is it simply resetting/restarting?

Thanks
Charly

I receive the following output in terminal:

I didn’t consider to look at my Terminal until now - thanks! I’ll look into the AttributeError statement.

@Charly_Wargnier
I converted wrapped both of the options arguments in list() and that seemed to solve the problem! Let me know if you think of anything else - but thank you for the help!

filter_playlist = filter_cols[0].multiselect('Playlist', options=list(np.sort(data['playlist'].unique())))
filter_artist = filter_cols[1].multiselect('Artist', options=list(np.sort(data['artist'].unique())))
1 Like

Glad it worked! :raised_hands:

Happy Streamlitin’! :balloon:

Best,
Charly

1 Like