What to do? - StreamlitAPIException: "Expected bytes, got a 'int' object"

Hi all,

I am facing a problem that when I return a table using “st.table(cap_stats)”, the following error message appears: StreamlitAPIException : (“Expected bytes, got a ‘int’ object”, ‘Conversion failed for column Uncapped with type object’)

I read in some places that it is bug that came with Streamlit 0.85.0, and a possible workaround is to convert DataFrame cells to strings with df.astype(str). I made it and it worked - see below.

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

But another solution is to use the old dataframe serializer by setting this in your .streamlit/config.toml.

[global]
dataFrameSerialization = "legacy"

Two questions:

  1. Is it a Streamlit bug?
  2. Where can I find the config.toml file?

Thank you

Hi @Renan_Lopes,

Thanks for posting!

Check out this doc, which describes the Streamlit config file options. The config file should be located at ~/.streamlit/config.toml for Mac/Linux.

Not sure if the behavior you’re describing is a bug related to that specific version of Streamlit, but I’d recommend upgrading to the latest version of Streamlit. If you can share a code snippet which demonstrates what cap_stats is, we can try to figure out the cause of the error.

Caroline :balloon:

1 Like

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