How to center columns

hi, i am trying to get a dataframe with columns center so I did:

                     .set_properties(**{"background-color": "white", "color": "black", "border-color": "black", 'text-align': 'center'})
                     .format("{:.2f}%", subset=(['Taux sans risque', 'Ann. return', '% Rdt>0', 'Average up', 'Average Down',
                                                 'Perf 2023', 'Perf 2022', 'Perf 2021', 'Perf 1 an', 'Perf 3 ans', 'Perf 5 ans'],
                     .format("{:.2f}%", subset=(['Up ratio', 'Down ratio'],
                                                ['portef', 'indice'])
                     .format("{:.2f}", subset=(['Skewness', 'kurtosis'],

but it seems that the 'text-align': 'center'did nothing.

Thx for your help.

Officially, styler support is experimental with only color and value explicitly available. You can convert your styler to html with the .to_html() method and then render it directly, but that would lose the interactivity.

import streamlit as st
import pandas as pd

df = pd.DataFrame({

styled_df =**{
    "background-color": "white", 
    "color": "black", 
    "border-color": "black", 
    'text-align': 'center'

st.write(styled_df.to_html(), unsafe_allow_html=True)


If there are specific aspects of styler you would like supported, I recommend checking GitHub for a current feature request to vote on or creating a new feature request so the devs can be aware of and track interest.

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