I need the selectbox default value to be a string such as: please select and then the data list to be all values of pd.DataFrame. How do I implement this function?
I wanted to add a default boot string to the selectbox to help the user click on the corresponding value, but when I used the DataFrame, I didn’t get what I wanted
After the program runs, the selectbox automatically executes the value of the first line. I want the user to select the corresponding option before executing it. For example, I want the effect to be as follows:
Sorry for the late response on this. It sounds like you’re looking to pass a DataFrame as the options for your st.selectbox, which you can do via the following:
import pandas as pd
import streamlit as st
data = {
"values": [420, 380, 390],
}
df = pd.DataFrame(data)
option = st.selectbox('Select an option ',options=df)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.