Skip to content

Instantly share code, notes, and snippets.

@treuille
Created October 30, 2019 22:18
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save treuille/e8f07ebcd92265a68ecec585f7594918 to your computer and use it in GitHub Desktop.
Save treuille/e8f07ebcd92265a68ecec585f7594918 to your computer and use it in GitHub Desktop.
Workaround: Selecting rows from a dataframe.
import streamlit as st
import pandas as pd
# Load some example data.
DATA_URL = \
"http://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz"
data = st.cache(pd.read_csv)(DATA_URL, nrows=1000)
# Select some rows using st.multiselect. This will break down when you have >1000 rows.
st.write('### Full Dataset', data)
selected_indices = st.multiselect('Select rows:', data.index)
selected_rows = data.loc[selected_indices]
st.write('### Selected Rows', selected_rows)
@acidicph
Copy link

Right now, you need to use a separate GUI element to select the row, which is what this gist shows. When we get the row-selectable dataframe, you will be able to select directly. If you have further questions about how to solve this scenario via Streamlit I would suggest the forums (discuss.streamlit.io) where a lot of people besides me can help you out! :)

On Wed, Jun 10 2020 at 12:58 PM, Ebrahim H Ghazvini Zadeh < @.*** > wrote: @.**** commented on this gist. Hi, again! Is there a way to input instead of selecting a row based on certain ID because my dataframe is a 100k row — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub ( https://gist.github.com/e8f07ebcd92265a68ecec585f7594918#gistcomment-3337540 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAMYONLF7MSMRWYOJ6U2KDDRV7QXBANCNFSM4JHBEHTA ).

Alright, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment