问题
Have to left align a description column in the pandas dataframe in python. Similar to left or right align a cell in excel sheet. is there any solution for this? Image attached for reference.
!Dataset
回答1:
Try this
df.style.set_properties(subset=["col1", "col2"], **{'text-align': 'right'})
回答2:
I think you can just remove the leading spaces.
df.Description = df.Description.apply(lambda row: row.lstrip(' '))
来源:https://stackoverflow.com/questions/53460941/how-to-left-align-a-dataframe-column-in-python