pandas.Series.str.partition

pandas 3.1.1 · Series and accessors · method

Split at the first separator, returning the portions before and after it plus the separator itself.

Call syntax

Series.str.partition(sep=' ', expand=True)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
sep Optional
Positional or keyword
Default ' '
str

Specify the separator between fields or string pieces.

expand Optional
Positional or keyword
Default True
bool

Choose whether to expand extracted pieces into separate columns.

Returns

DataFrame/MultiIndex or Series/Index of objects