cudf.core.column.string.StringMethods.like#

StringMethods.like(pat: str, esc: str = None) SeriesOrIndex#

Test if a like pattern matches a string of a Series or Index.

Return boolean Series or Index based on whether a given pattern matches strings in a Series or Index.

Parameters
patstr

Pattern for matching. Use ‘%’ for any number of any character including no characters. Use ‘_’ for any single character.

escstr

Character to use if escape is necessary to match ‘%’ or ‘_’ literals.

Returns
Series/Index of bool dtype

A Series/Index of boolean dtype indicating whether the given pattern matches the string of each element of the Series/Index.

Examples

>>> import cudf
>>> s = cudf.Series(['abc', 'a', 'b' ,'ddbc', '%bb'])
>>> s.str.like('%b_')
0   False
1   False
2   False
3   True
4   True
dtype: boolean

Parameter esc can be used to match a wildcard literal.

>>> s.str.like('/%b_', esc='/' )
0   False
1   False
2   False
3   False
4   True
dtype: boolean