I have erro ValueError: 0 is not in iterable

Hi I got this error

King_County_App.py:49: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data.drop(data.index[data['sqft_basement'] == '?'], inplace = True)

King_County_App.py:50: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['bedrooms'] = data['bedrooms'].replace(33, 3)

King_County_App.py:58: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['dormitory_type'] = data['bedrooms'].apply( lambda x: 'studio' if x == 1 else

King_County_App.py:62: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['condition_status'] = data['condition'].sort_values(ascending=True).apply( lambda x: 'critical' if x == 1 else

King_County_App.py:72: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['is_waterfront'] = data['waterfront'].apply( lambda x: 'yes' if x == 1 else'no')

2022-11-12 03:45:51.457 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script

    exec(code, module.__dict__)

  File "King_County_App.py", line 83, in <module>

    bedrooms_min = st.sidebar.select_slider("Min of Bedrooms",

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/select_slider.py", line 122, in select_slider

    return self._select_slider(

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/select_slider.py", line 180, in _select_slider

    slider_value = as_index_list(value)

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/select_slider.py", line 172, in as_index_list

    return [index_(opt, v)]

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/util.py", line 131, in index_

    raise ValueError("{} is not in iterable".format(str(x)))

ValueError: 0 is not in iterable

King_County_App.py:49: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data.drop(data.index[data['sqft_basement'] == '?'], inplace = True)

King_County_App.py:50: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['bedrooms'] = data['bedrooms'].replace(33, 3)

King_County_App.py:58: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['dormitory_type'] = data['bedrooms'].apply( lambda x: 'studio' if x == 1 else

King_County_App.py:62: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['condition_status'] = data['condition'].sort_values(ascending=True).apply( lambda x: 'critical' if x == 1 else

King_County_App.py:72: SettingWithCopyWarning: 

A value is trying to be set on a copy of a slice from a DataFrame.

Try using .loc[row_indexer,col_indexer] = value instead


See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

  data['is_waterfront'] = data['waterfront'].apply( lambda x: 'yes' if x == 1 else'no')

2022-11-12 03:50:30.350 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script

    exec(code, module.__dict__)

  File "King_County_App.py", line 83, in <module>

    bedrooms_min = st.sidebar.select_slider("Min of Bedrooms",

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/select_slider.py", line 122, in select_slider

    return self._select_slider(

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/select_slider.py", line 180, in _select_slider

    slider_value = as_index_list(value)

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/elements/select_slider.py", line 172, in as_index_list

    return [index_(opt, v)]

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/util.py", line 131, in index_

    raise ValueError("{} is not in iterable".format(str(x)))

ValueError: 0 is not in iterable

My github GitHub - khanhhua2405/house-prices at hi
Can anyone know how to fix this?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.