I’m trying to run a function that works perfectly well outside of Streamlit, but when I try to display the outcome of that function on my Streamlit App, it displays structural elements of my function instead.
The name of my function is “reco” - it’s basically a recommandation system for audio tracks. So when given a track, the function will advise you on another track to listen to.
Here’s the very beginning of what my function looks like in Python (but again, it works fine on its own) :
OG_track = “Taylor Swift - Blank Space”
if option != OG_track:
st.write(“You picked the track :”, option)
track = str(option)
reco1 = reco(track)
st.write(track)
OG_track being a track used as an example, then the user can select another track using a selectbox.
Option is the outcome of what’s been selected using the selectbox.
If I select for instance the track Chris Stapleton - Tennessee Whiskey, here’s what’s displayed on my Streamlit App:
That is not in the code snippet though. What is the list of options that you are passing to st.selectbox? Is it some composition of df_track and artist values?
The lists rendered on the app come from these lines that seem to be part of your .loc[] expression but they are actually independent statements, just because they are in new lines.
I was able to solve the issue I had with the multiple statements, thanks to your help.
But there’s still a problem somewhere with my function, as Streamlit returns “None” instead of an actual value
It must have something to do with the way I’m trying to run the function in Streamlit because the function does have a correct output when it’s being run outside of Streamlit :