cudf.core.column.string.StringMethods.partition#

StringMethods.partition(sep: str = ' ', expand: bool = True) SeriesOrIndex[source]#

Split the string at the first occurrence of sep.

This method splits the string at the first occurrence of sep, and returns 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.

Parameters:
sepstr, default ‘ ‘ (whitespace)

String to split on.

Returns:
DataFrame or MultiIndex

Returns a DataFrame / MultiIndex

See also

rpartition

Split the string at the last occurrence of sep.

split

Split strings around given separators.

Examples

>>> import cudf
>>> s = cudf.Series(['Linda van der Berg', 'George Pitt-Rivers'])
>>> s
0    Linda van der Berg
1    George Pitt-Rivers
dtype: object
>>> s.str.partition()
        0  1             2
0   Linda     van der Berg
1  George      Pitt-Rivers

To partition by something different than a space:

>>> s.str.partition('-')
                    0  1       2
0  Linda van der Berg
1         George Pitt  -  Rivers

Also available on indices:

>>> idx = cudf.Index(['X 123', 'Y 999'])
>>> idx
Index(['X 123', 'Y 999'], dtype='object')

Which will create a MultiIndex:

>>> idx.str.partition()
MultiIndex([('X', ' ', '123'),
            ('Y', ' ', '999')],
           )

Pandas Compatibility Note

pandas.Series.str.partition()

The parameter expand is not yet supported and will raise a NotImplementedError if anything other than the default value is set.