How to set the pandas dataframe data left/right alignment?

后端 未结 6 995
礼貌的吻别
礼貌的吻别 2020-11-30 05:23

I use pd.set_option(\"display.colheader_justify\",\"right\") to set the column header. But I can\'t find the option for data by pd.describe_option()

6条回答
  •  广开言路
    2020-11-30 06:23

    If you wanna align both text and header to the left for example you can use:

    df.style.set_properties(**{'text-align': 'left'}).set_table_styles([ dict(selector='th', props=[('text-align', 'left')] ) ])
    

    This first sets the text to the left and then the header.

提交回复
热议问题