Floats rendering incorrectly in st.dataframe

I’ve been struggling to figure out how to resolve this issue and have tried everything I can think of and can’t figure out how to resolve it.
Basically, whenever a float value has a leading 0.0 all leading 0s are being removed before the dataframe is rendered in streamlit.

Here is a screenshot of what shows in streamlit:
SNAG-2023-09-19_11-40-58_AM

Here is a screenshot of the df in my IDE before it is added to streamlit:
SNAG-2023-09-19_11-42-26_AM

You can see the “Executive & Admin” value is 0.091400 but in the streamlit UI it shows it as 91400.

If there are more leading 0s like 0.0000100 it would just show as 100. No idea why and not sure what to do to fix it?

I am using streamlit 1.26.0 on python 3.9.13

Works as expected here. You must be doing something different.

It works totally fine if I manually create a data frame and type in 0.00123, but if the data comes from a query from st.experimental_connection, it doesn’t seem to work

Is df a pandas DataFrame or something else?

What connection type is being used?

Using the snowpark connection. I’ve tried both the direct result from the snowpark connection.query(sql) as well as taking that result and attempting to convert it to a pandas dataframe (even though I’m pretty sure that query returns a pandas dataframe).
I have a feeling if you connect to snowflake via snowpark and do something as simple as select 0.000123 as f and put those results into the table, it wouldn’t render correctly, but haven’t tried it yet…

If you can reproduce the issue with a pandas DataFrame, there must be a way to share it.

This could be a Pandas styling issue, not displaying the float appropriately.

Try this:

st.dataframe(df.style.format({"f": "{:.6f}"}), use_container_width=True)

@CarlosSerrano is there any way to do this generically? Ideally a solution that formats float columns as float, but non-float columns as ints and strings? I guess I could look at the data to do this, but was hoping for a “simpler” solution.