Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when using select_slider #25

Open
444B opened this issue Mar 2, 2024 · 4 comments
Open

KeyError when using select_slider #25

444B opened this issue Mar 2, 2024 · 4 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@444B
Copy link
Owner

444B commented Mar 2, 2024

Original issue by upasana-mittal on 2023-02-02 22:13:34+00:00

I am getting a key error at st.select slider

start_rating, end_rating = st.select_slider("Select range of CSAT", options=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], value=(2, 4))

KeyError: (2, 4)

@444B
Copy link
Owner Author

444B commented Mar 2, 2024

@upasana-mittal is this still relevant?

@444B 444B self-assigned this Mar 2, 2024
@444B 444B added bug Something isn't working good first issue Good for newcomers labels Mar 3, 2024
@cakechaser
Copy link

I'm also getting this issue with st.radio: KeyError: 'LTM'

File ".../streamlit/runtime/scriptrunner/script_runner.py", line 600, in _run_script
    exec(code, module.__dict__)
line 33, in <module>
    selector_screen = st.sidebar.radio(
File ".../streamlit_analytics2/main.py", line 180, in new_func
    counts["widgets"][label][selected] += 1

Selector code:

selector_screen = st.sidebar.radio(
    'Screen:',
    get_all_screens(st.session_state['screen_sorting']),
    key='screen_selector'
)

If I use a hardcoded list for options ['a', 'b'], I don't get this issue.

@444B
Copy link
Owner Author

444B commented Jun 6, 2024

@cakechaser thanks for validating the bug!
I'll take a look into this and see if I can fix it

@cakechaser
Copy link

@444B thanks for the quick reply!
I actually just fixed it on my side.

The get_all_screens function for the radio options was returning a pandas dataframe.
I changed it to return a single column from the dataframe, and now the issue has disappeared.

Basically changing return df to return df['Column Name']

However streamlit itself is rendering the selector without issues regardless of this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants