St.dataframe output formating

Summary

i have some serial number in an excelsheet which being loaded into dataframe and then displayed st.dataframe(df_name), but the output comes as comma formated… but as its a serial number, i just to display it as number.
ex:
image

but I want display it as full number, with out comma’s and desimals

You can style the dataframe before passing it to st.dataframe. Check the docs on formatting values: Table Visualization — pandas 1.5.3 documentation

Code:
import streamlit as st
import pandas as pd
import numpy as np

df = pd.DataFrame(
    {
        "Serial Number": np.arange(1_000_000_000, 2_000_000_000, 100_000_000),
        "Some number": np.arange(1, 2, 0.1)
    }
)

cols = st.columns(2)

with cols[0]:
    "## 🐻‍❄️ Default"
    st.dataframe(df)

with cols[1]:
    "## 😎 With style"
    st.dataframe(
        df.style.format({
            "Serial Number": "{}", # Show no formatting
            "Some number" : "{:.2f}" # Show a float with two decimals
        })
    )
1 Like

Thank you!..it worked

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