Table Of Contents


Enter search terms or a module, class or function name.


Series.str.partition(pat=' ', expand=True)[source]

Split the string at the first occurrence of sep, and return 3 elements containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return 3 elements containing the string itself, followed by two empty strings.


pat : string, default whitespace

String to split on.

expand : bool, default True

  • If True, return DataFrame/MultiIndex expanding dimensionality.
  • If False, return Series/Index.

split : DataFrame/MultiIndex or Series/Index of objects

See also

Split the string at the last occurrence of sep


>>> s = Series(['A_B_C', 'D_E_F', 'X'])
0    A_B_C
1    D_E_F
2        X
dtype: object
>>> s.str.partition('_')
   0  1    2
0  A  _  B_C
1  D  _  E_F
2  X
>>> s.str.rpartition('_')
     0  1  2
0  A_B  _  C
1  D_E  _  F
2          X
Scroll To Top