How to left align column headers and values in a dataframe?

I am very new to Streamlit. Pls help me.

pd.option_context(‘colheader_justify’, ‘left’)
pd.set_option(‘colheader_justify’, ‘left’)

The above commands do not work.

df2=outputdframe.style.set_properties(**{‘text-align’: ‘left’}).set_table_styles([dict(selector=‘th’, props=[(‘text-align’, ‘left’)])])

With the above line, only the data values align to left but not the column headers.

Hey @VISHNU_SASTRY_H_K_CS Welcome to the community !

Its hacky but I think this should work,
( It will force alignment of all of the dataframe content of all of your dataframes to left )

st.markdown(
    """<style>
        .dataframe {text-align: left !important}
    </style>
    """, unsafe_allow_html=True) 
2 Likes