Selectbox error in a specific value

[UPDATE: SOLVED by using unqiue() instead of drop_duplicates()

hi, I am just starting working on some tutorials. I am trying to create a selectbox filter for the Pclass variable in the titanic dataaset, the issue is I am getting an error when I select (2). I looked at the data but still not sure why it throws an error. Thanks for your help

import streamlit as st
st.set_page_config(page_title=None, page_icon=None,
                   layout='centered', initial_sidebar_state='auto')
import pandas as pd
import numpy as np

st.title('Your Titanic survival estimate')
DATA_URL = ('https://gist.githubusercontent.com'
            '/michhar/2dfd2de0d4f8727f873422c5d959fff5/raw'
            '/fa71405126017e6a37bea592440b4bee94bf7b9e/titanic.csv')

@st.cache
def load_data():
    data = pd.read_csv('titanic.csv')
    return data

data_load_state = st.text('Loading data...')
data = load_data()
data_load_state.text("Done! (using st.cache)")

pclass = data['Pclass'].drop_duplicates()
pclass_drop = st.sidebar.selectbox("Pclass",pclass)

Hi @atheeralattar, welcome to the Streamlit community!! :wave: :partying_face:

I’m glad you found a solution!

Happy Streamlit-ing! :balloon:
Snehan

1 Like