cudf.core.column.string.StringMethods.center#

StringMethods.center(width: int, fillchar: str = ' ') SeriesOrIndex#

Filling left and right side of strings in the Series/Index with an additional character.

Parameters
widthint

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

fillcharstr, default is ‘ ‘ (whitespace)

Additional character for filling.

Returns
Series/Index of str dtype

Returns Series or Index.

Examples

>>> import cudf
>>> s = cudf.Series(['a', 'b', None, 'd'])
>>> s.str.center(1)
0       a
1       b
2    <NA>
3       d
dtype: object
>>> s.str.center(1, fillchar='-')
0       a
1       b
2    <NA>
3       d
dtype: object
>>> s.str.center(2, fillchar='-')
0      a-
1      b-
2    <NA>
3      d-
dtype: object
>>> s.str.center(5, fillchar='-')
0    --a--
1    --b--
2     <NA>
3    --d--
dtype: object
>>> s.str.center(6, fillchar='-')
0    --a---
1    --b---
2      <NA>
3    --d---
dtype: object