pandas.Series.str.rpartition — pandas 0.18.1 documentation (original) (raw)
Series.str.rpartition(pat=' ', expand=True)¶
Split the string at the last 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 two empty strings, followed by the string itself.
Parameters: | pat : string, default whitespace String to split on. expand : bool, default True If True, return DataFrame/MultiIndex expanding dimensionality. If False, return Series/Index. |
---|---|
Returns: | split : DataFrame/MultiIndex or Series/Index of objects |
See also
Split the string at the first occurrence of sep
Examples
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