pyspark.pandas.Series.str.pad#

str.pad(width, side='left', fillchar=' ')#

Pad strings in the Series up to width.

Parameters
widthint

Minimum width of resulting string; additional characters will be filled with character defined in fillchar.

side{‘left’, ‘right’, ‘both’}, default ‘left’

Side from which to fill resulting string.

fillcharstr, default ‘ ‘

Additional character for filling, default is whitespace.

Returns
Series of object

Returns Series with minimum number of char in object.

Examples

>>> s = ps.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