pandas.Series.str.center

pandas 3.1.1 · Series and accessors · method

Pad both sides of each string to reach a minimum width.

Call syntax

Series.str.center(width, fillchar=' ')

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
width Required
Positional or keyword
int

Set the requested width of the formatted result.

fillchar Optional
Positional or keyword
Default ' '
str

Choose the character used to pad strings.

Returns

Series/Index of objects.