cudf.core.column.string.StringMethods.pad#

StringMethods.pad(width: int, side: str = 'left', fillchar: str = ' ') SeriesOrIndex#

Pad strings in the Series/Index 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 ‘ ‘ (whitespace)

Additional character for filling, default is whitespace.

Returns
Series/Index of object

Returns Series or Index with minimum number of char in object.

See also

rjust

Fills the left side of strings with an arbitrary character. Equivalent to Series.str.pad(side='left').

ljust

Fills the right side of strings with an arbitrary character. Equivalent to Series.str.pad(side='right').

center

Fills boths sides of strings with an arbitrary character. Equivalent to Series.str.pad(side='both').

zfill

Pad strings in the Series/Index by prepending ‘0’ character. Equivalent to Series.str.pad(side='left', fillchar='0').

Examples

>>> import cudf
>>> s = cudf.Series(["caribou", "tiger"])
>>> 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