Decimals not displayed correctly in DF

Decimals not displayed in the front end when using streamlit.write or streamlit.dataframe.
Output should have 2 decimals

Code
st.write(df)

During Debugging
image

Display
image

Hi @Sarangan_Rajendren , is there a code snippet that you could paste? What I could see happening is that the numbers are too big and as a result, it could be that they’re not showing the decimals.

From this code snippet, I can see that there are decimals being presented:

# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np
import pandas as pd

import streamlit as st

# Explicitly seed the RNG for deterministic results
np.random.seed(0)

data = np.random.randn(100, 100)

df = pd.DataFrame(data)
st._arrow_dataframe(df)

Thank you for your response
I have identified the issue.It was due to columns came as “Decimals()” and converted to the df.

Using the following statement solved the issue and converted the decimals to Float

pd.to_numeric(df[“Open”], downcast=“float”)

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