Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix StreamlitAPIException: ("Expected bytes, got a 'int' object", 'Conversion failed for column FG% with type object')

Error:

StreamlitAPIException: ("Expected bytes, got a 'int' object", 'Conversion failed for column FG% with type object')

Error Traceback

Traceback:
File "C:\Users\ASUS\streamlit_freecodecamp-main\app_3_eda_basketball\basketball_app.py", line 44, in <module>
    st.dataframe(df_selected_team)
like image 832
Fikri Sambasri Avatar asked Dec 31 '22 12:12

Fikri Sambasri


1 Answers

It’s a bug that came with streamlit 0.85.0. pyarrow has an issue with numpy.dtype values (which df.dtypes returns).

The issue has been filed and hopefully will be taken care of soon.

A possible workaround is to convert DataFrame cells to strings with df.astype(str)

In your case

test = df_selected_team.astype(str)
st.dataframe(test)

or

downgrade your streamlit version to 0.84

or

A preferable solution for this is to use the old dataframe serializer by setting this in your .streamlit/config.toml file:

[global]
dataFrameSerialization = "legacy"

This allows you to continue upgrading to the latest version of Streamlit.

Follow this thread for more updates

like image 152
Pluviophile Avatar answered Jan 04 '23 15:01

Pluviophile