Streamlit doesn't display pandas data frame

Hello, I am transposing a pandas df, and trying to print out using st.table().
The code:

from astroquery.ipac.ned import Ned

objectInput = 'ABELL 2218'
result_tableNED = Ned.query_object(objectInput)
dataFrameObjectNED = result_tableNED.to_pandas()
st.table(dataFrameObjectNED.T)

Error:

StreamlitAPIException: ("Could not convert 'ABELL 2218' with type str: tried to convert to int64", 'Conversion failed for column 0 with type object')

Same code in jupyter works fine but without using streamlit.
Thank you

It’s a bit of a hack, but if you’re just trying to display the data, you can convert it all to strings, then either display it with st.table or st.dataframe

import streamlit as st
from astroquery.ipac.ned import Ned

objectInput = "ABELL 2218"
result_tableNED = Ned.query_object(objectInput)
dataFrameObjectNED = result_tableNED.to_pandas()

dataFrameObjectNED = dataFrameObjectNED.astype(str)

st.table(dataFrameObjectNED.T)
st.dataframe(dataFrameObjectNED.T)

Thank you, will try it!

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