cudf.core.column.string.StringMethods.insert#

StringMethods.insert(start: int = 0, repl: str | None = None) SeriesOrIndex#

Insert the specified string into each string in the specified position.

Parameters:
startint

Beginning position of the string to replace. Default is beginning of the each string. Specify -1 to insert at the end of each string.

replstr

String to insert into the specified position value.

Returns:
Series/Index of str dtype

A new string series with the specified string inserted at the specified position.

Examples

>>> import cudf
>>> s = cudf.Series(["abcdefghij", "0123456789"])
>>> s.str.insert(2, '_')
0    ab_cdefghij
1    01_23456789
dtype: object

When no repl is passed, nothing is inserted.

>>> s.str.insert(2)
0    abcdefghij
1    0123456789
dtype: object

Negative values are also supported for start.

>>> s.str.insert(-1,'_')
0    abcdefghij_
1    0123456789_
dtype: object