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
Display
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
Display
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.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.