dataprofessor / streamlit_freecodecamp

Build 12 Data Apps in Python with Streamlit
577 stars 541 forks source link

Error for Boston House Regression - Data format #1

Open paluigi opened 3 years ago

paluigi commented 3 years ago

Hello, while launching the boston house regression app (app 9) I get this error:

KeyError: <class 'numpy.float64'> Traceback: File "/home/xxx/anaconda3/envs/stl/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script exec(code, module.dict) File "/home/xxx/github/streamlit_freecodecamp/app_9_regression_boston_housing/boston-house-ml-app.py", line 54, in df = user_input_features() File "/home/xxx/github/streamlit_freecodecamp/app_9_regression_boston_housing/boston-house-ml-app.py", line 25, in user_input_features CRIM = st.sidebar.slider('CRIM', X.CRIM.min(), X.CRIM.max(), X.CRIM.mean()) File "/home/xxx/anaconda3/envs/stl/lib/python3.8/site-packages/streamlit/elements/slider.py", line 159, in slider data_type = SUPPORTED_TYPES[type(value[0])]

It seems there something odd between the format in which data in the sidebar are saved and the way the program expects them? Any help is appreciated! Thanks

Jannik098 commented 3 years ago

Hey there, I'm not an expert myself but the problem is that streamlit complains about the min() and max() returning int64 instead of int. I found it here: https://github.com/streamlit/streamlit/issues/1065#issue-561821222

If you adjust all the sliders like this, it works for me: CRIM = st.sidebar.slider('CRIM', float(X.CRIM.min()), float(X.CRIM.max()), float(X.CRIM.mean()))

amulya25p commented 1 year ago

Hey there, I'm not an expert myself but the problem is that streamlit complains about the min() and max() returning int64 instead of int. I found it here: streamlit/streamlit#1065 (comment)

If you adjust all the sliders like this, it works for me: CRIM = st.sidebar.slider('CRIM', float(X.CRIM.min()), float(X.CRIM.max()), float(X.CRIM.mean()))

this worked for me! Thanks!