Number with a space for thousands separator to be aligned to the right

In a dataframe i want to right align a numbers with a space for thousands separator. The problem is that when numbers are with space for thousands separator, they become a string and automatically aligned to the left.

You can pass a pandas styler object to st.dataframe to show a dataframe with specific styling. For example:

import pandas as pd
import streamlit as st

df = pd.DataFrame({"nums": [12345, 67890, 12345667890]})

st.dataframe(df.head().style.format(thousands=" "), use_container_width=True)

Thank you @blackary,

Now I have space for thousands separator, but the digits after the decimal point became 6.
What I want is rounded to whole number, with a space for thousands separator, and aligned to right.


You can also pass precision=0 to style.format to only show them as integers. They will be right-aligned by default.

See — pandas 1.5.0 documentation for more options

Thank you very much @blackary !
This is exactly what I was looking for:

st.dataframe(" ", precision=0))

1 Like

If anyone knows how I could apply the same thing with streamlit-aggrid too, that would be great.
I didn’t find anything similar in the documentation, there must be some complicated solution I guess, but I would like to see a more optimal one.

I am also looking to align numbers right on st-aggrid