26

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)
1
  • 2
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Oct 16, 2021 at 5:24

2 Answers 2

34

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

3
  • 1
    Great! I used the "legacy" option, and it works just fine. Every problem has a solution here already, marvellous! Commented Nov 24, 2021 at 3:44
  • 1
    Using 'legacy' serializer will negate the benefits from the new Arrow based data frame serializer if your data frame size is large. So suggest using str conversion before display as interim.
    – sudheer
    Commented Feb 16, 2022 at 12:24
  • Take care, in modern versions streamlit warnings "global.dataFrameSerialization IS NO LONGER SUPPORTED. Legacy serialization has been removed. All dataframes will be serialized using Apache Arrow.". Therefore, the "legacy" option will not work. Commented Aug 8 at 7:09
0

I had the same problem. Then I downgraded my streamlit version to make it work, currently, I'm running streamlit 0.75.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.