Pad strings in the Series/Index up to width.
Minimum width of resulting string; additional characters will be filled with character defined in fillchar.
Side from which to fill resulting string.
Additional character for filling, default is whitespace.
Returns Series or Index with minimum number of char in object.
See also
Series.str.rjustFills the left side of strings with an arbitrary character. Equivalent to Series.str.pad(side='left').
Series.str.ljustFills the right side of strings with an arbitrary character. Equivalent to Series.str.pad(side='right').
Series.str.centerFills both sides of strings with an arbitrary character. Equivalent to Series.str.pad(side='both').
Series.str.zfillPad strings in the Series/Index by prepending ‘0’ character. Equivalent to Series.str.pad(side='left', fillchar='0').
Examples
>>> s = pd.Series(["caribou", "tiger"])
>>> s
0 caribou
1 tiger
dtype: object
>>> s.str.pad(width=10)
0 caribou
1 tiger
dtype: object
>>> s.str.pad(width=10, side='right', fillchar='-')
0 caribou---
1 tiger-----
dtype: object
>>> s.str.pad(width=10, side='both', fillchar='-')
0 -caribou--
1 --tiger---
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.pad.html