St.dataframe behaviour

Any idea why st.dataframe(df) converts integer columns to string? It sorts the columns based on ASCII values.

My dataframe has three columns. Two of them are of type integer, and one is string.

Does it gets converted to string internally?

I am using the latest version of streamlit.

Hell @ahairshi, thanks for reporting this issue. Unfortunately, only int64 and float64 types are currently actually resolved as numbers, which means that it gets right-aligned, and sorting works based on the numbers and not the string representation.

The best workaround at the moment is to change your values in the dataframe to int64 or float64.


Thanks for your reply. I will make the necessary changes.

_legacy_dataframe treats int32 as integer, but left aligned. @lukasmasuch

Indeed, the issue is related to the arrow data serialization. The legacy data serialization should handle these values correctly :+1:

1 Like

Itโ€™s been several months โ€“ since I read about this issue that requires us to select legacy serialization. Whatโ€™s the timeframe on the upstream or streamlit changes that will resolve this? Surely we canโ€™t rely on the โ€œlegacyโ€ implementation forever.

This issue is solved in the current version of st.dataframe