How to use the streamlit.slider function in streamlit

To help you get started, we’ve selected a few streamlit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MarcSkovMadsen / awesome-streamlit / gallery / table_experiments / app.py View on Github external
def select_number_of_rows_and_columns(results: pd.DataFrame, key: str):
    rows = st.selectbox(
        "Select number of table rows to display",
        options=[5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, len(results)],
        key=key,
    )
    columns = st.slider(
        "Select number of table columns to display",
        0,
        len(results.columns) - 1,
        DEFAULT_NUMBER_OF_COLUMNS,
        key=key,
    )
    style = st.checkbox("Style dataframe?", False, key=key)
    return rows, columns, style
github arvkevi / nba-roster-turnover / roster_turnover.py View on Github external
f"""
    Source Data: [Player Minutes]({PLAYER_MINUTES_GITHUB}), [Roster Turnover]({ROSTER_TURNOVER_GITHUB}),
    [Teams Data]({TEAMS_DATA_GITHUB})
        """
    )

    # Loading data
    with st.spinner("Loading data ..."):
        image = get_image()
        player_minutes = load_player_minutes().copy(deep=True)
        roster_turnover = load_roster_turnover().copy(deep=True)
        team_colors = load_teams_colors()
        wins_turnover_corr = load_wins_turnover_corr(roster_turnover)

    st.header("Correlation by year")
    year = st.slider("Select a Year", 2004, 2019)
    teams = get_teams(year)
    teams_colorscale = get_teams_colorscale(teams, team_colors)

    st.write(f"Correlation Coefficient: {wins_turnover_corr[year]}")
    st.sidebar.image(image, use_column_width=True)
    st.sidebar.markdown(
        "Explore NBA roster turnover since\nthe 2003-04 season. **Roster turnover** is \ndefined as the "
        "sum of the absolute difference\nin total minutes played by each player\non a given team between any two "
        "years."
    )
    st.sidebar.table(
        pd.DataFrame.from_dict(
            wins_turnover_corr, orient="index", columns=["correlation"]
        ).round(2)
    )
github streamlit / streamlit / examples / checkboxes.py View on Github external
width=0,
    )

    image.putalpha(alpha)

    return np.array(image).astype("float") / 255.0


if True:
    st.title("Image, checkbox and slider test")

    st.write("Script ran at", datetime.datetime.now().isoformat())

    st.subheader("Background color")
    r_color = st.slider("Red amount", 0, 100)
    g_color = st.slider("Green amount", 0, 100)
    b_color = st.slider("Blue amount", 0, 100)
    alpha_pct = st.slider("Alpha amount", 0, 100, 50)

    image = create_image(r_color, g_color, b_color, alpha_pct)
    r = image[:, :, 0]
    g = image[:, :, 1]
    b = image[:, :, 2]
    alpha = image[:, :, 3]

    z = np.zeros(r.shape)
    mask = np.ones(r.shape)

    image = np.stack([r, g, b], 2)

    st.subheader("Channels to include in output")
    r_on = st.checkbox("Red", True)
github MarcSkovMadsen / awesome-streamlit / gallery / nba_roster_turnover / roster_turnover.py View on Github external
f"""
    Source Data: [Player Minutes]({PLAYER_MINUTES_GITHUB}), [Roster Turnover]({ROSTER_TURNOVER_GITHUB}),
    [Teams Data]({TEAMS_DATA_GITHUB})
        """
    )

    # Loading data
    with st.spinner("Loading data ..."):
        image = get_image()
        player_minutes = load_player_minutes().copy(deep=True)
        roster_turnover = load_roster_turnover().copy(deep=True)
        team_colors = load_teams_colors()
        wins_turnover_corr = load_wins_turnover_corr(roster_turnover)

    st.header("Correlation by year")
    year = st.slider("Select a Year", 2004, 2019)
    teams = get_teams(year)
    teams_colorscale = get_teams_colorscale(teams, team_colors)

    st.write(f"Correlation Coefficient: {wins_turnover_corr[year]}")
    st.sidebar.image(image, use_column_width=True)
    st.sidebar.markdown(
        "Explore NBA roster turnover since\nthe 2003-04 season. **Roster turnover** is \ndefined as the "
        "sum of the difference\nin total minutes played by each player\non a given team between any two "
        "years."
    )
    st.sidebar.table(
        pd.DataFrame.from_dict(
            wins_turnover_corr, orient="index", columns=["correlation"]
        ).round(2)
    )
github MarcSkovMadsen / awesome-streamlit / scratchpad / issues_streamlit / issue_main_thread_is_not_in_main_loop.py View on Github external
def plot_section():
    st.markdown(
        """
## Interactive plot - Streamlit

"""
    )
    x = get_x()
    mu = st.slider(
        "mu", value=float(0), min_value=float(-5), max_value=float(5), step=float(0.1)
    )
    sigma = st.slider(
        "sigma",
        value=float(1),
        min_value=float(0.1),
        max_value=float(5),
        step=float(0.1),
    )
    plot_figure(x, mu, sigma)
github MarcSkovMadsen / awesome-streamlit / gallery / iris_eda_app / iris_eda_app.py View on Github external
if species_type == "Setosa":
        st.text("Showing Setosa Species")
        st.image(load_image("imgs/iris_setosa.jpg"), width=400)
    elif species_type == "Versicolor":
        st.text("Showing Versicolor Species")
        st.image(load_image("imgs/iris_versicolor.jpg"), width=400)
    elif species_type == "Virginica":
        st.text("Showing Virginica Species")
        st.image(load_image("imgs/iris_virginica.jpg"), width=400)

    # Show Image or Hide Image with Checkbox
    if st.checkbox("Show Image/Hide Image"):
        my_image = load_image("iris_setosa.jpg")
        enh = ImageEnhance.Contrast(my_image)
        num = st.slider("Set Your Contrast Number", 1.0, 3.0)
        img_width = st.slider("Set Image Width", 300, 500)
        st.image(enh.enhance(num), width=img_width)

    # About
    if st.button("About App"):
        st.subheader("Iris Dataset EDA App")
        st.text("Built with Streamlit")
        st.text("Thanks to the Streamlit Team Amazing Work")

    if st.checkbox("By"):
        st.text("Jesse E.Agbe(JCharis)")
        st.text("Jesus Saves@JCharisTech")
github streamlit / demo-uber-nyc-pickups / app.py View on Github external
[See source code](https://github.com/streamlit/demo-uber-nyc-pickups/blob/master/app.py)
""")

@st.cache(persist=True)
def load_data(nrows):
    data = pd.read_csv(DATA_URL, nrows=nrows)
    lowercase = lambda x: str(x).lower()
    data.rename(lowercase, axis="columns", inplace=True)
    data[DATE_TIME] = pd.to_datetime(data[DATE_TIME])
    return data


data = load_data(100000)

hour = st.slider("Hour to look at", 0, 23)

data = data[data[DATE_TIME].dt.hour == hour]

st.subheader("Geo data between %i:00 and %i:00" % (hour, (hour + 1) % 24))
midpoint = (np.average(data["lat"]), np.average(data["lon"]))

st.write(pdk.Deck(
    map_style="mapbox://styles/mapbox/light-v9",
    initial_view_state={
        "latitude": midpoint[0],
        "longitude": midpoint[1],
        "zoom": 11,
        "pitch": 50,
    },
    layers=[
        pdk.Layer(
github NishantGhanate / PythonScripts / Streamlit / 1_slider.py View on Github external
import streamlit as st
x = st.slider('x')
st.write(x, 'squared is', x * x)


values = st.slider('Select a range of values',  0, 100, (50))
st.write('Values:', values)


values1 = st.slider('Select a range of values',  0, 100, (25,50))
st.write('Values:', values1)

values2 = st.slider('Select a range of values', (50))
st.write('Values:', values2)
github MarcSkovMadsen / awesome-streamlit / gallery / owid_dashboard / owid_dashboard.py View on Github external
def view(self):
        """Map dashboard"""
        st.markdown(__doc__)
        self.dataset_name = st.selectbox("Select Data Set", options=self.dataset_names, index=0)
        self.year = st.slider(
            "Select Year",
            min_value=self.year_range[0],
            max_value=self.year_range[1],
            value=self.year,
        )
        st.bokeh_chart(self.map_plot())
        st.markdown(INFO)
        st.markdown(self.download_link(), unsafe_allow_html=True)
github zacheberhart / Learning-to-Feel / src / app.py View on Github external
# load all data
	df = load_data()
	non_label_cols = ['track_id', 'track_title', 'artist_name', 'track_popularity', 'artist_popularity']
	dims = [c for c in df.columns.tolist() if c not in non_label_cols]

	# Mood or Emotion Selection
	st.title('Explore All Moods & Emotions')
	st.write('''
		Select a mood, an emotion, or a few of each! However, keep in mind that results are best when
		you choose as few as possible -- though you will definitely get some pretty funky results the more you add.
	''')

	# filters
	labels = st.multiselect("Choose:", dims)
	n_songs = st.slider('How many songs?', 1, 100, 20)
	popularity = st.slider('How popular?', 0, 100, (0, 100))

	try:

		# filter data to the labels the user specified
		cols = (non_label_cols, labels)
		df = filter_data(df, cols, n_songs, popularity)

		# show data
		if st.checkbox('Include Preview URLs', value = True):
			df['preview'] = add_stream_url(df.track_id)
			df['preview'] = df['preview'].apply(make_clickable, args = ('Listen',))
			data = df.drop('track_id', 1)
			data = data.to_html(escape = False)
			st.write(data, unsafe_allow_html = True)
		else: