Pad left and right side of strings in the Series/Index.
Equivalent to str.center().
Minimum width of resulting string; additional characters will be filled with fillchar.
Additional character for filling, default is whitespace.
Examples
For Series.str.center:
>>> ser = pd.Series(['dog', 'bird', 'mouse'])
>>> ser.str.center(8, fillchar='.')
0 ..dog...
1 ..bird..
2 .mouse..
dtype: object
For Series.str.ljust:
>>> ser = pd.Series(['dog', 'bird', 'mouse'])
>>> ser.str.ljust(8, fillchar='.')
0 dog.....
1 bird....
2 mouse...
dtype: object
For Series.str.rjust:
>>> ser = pd.Series(['dog', 'bird', 'mouse'])
>>> ser.str.rjust(8, fillchar='.')
0 .....dog
1 ....bird
2 ...mouse
dtype: object
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.Series.str.center.html