verticapy.vDataColumn.str_contains#
- vDataColumn.str_contains(pat: str) vDataFrame #
Verifies if the regular expression is in each of the vDataColumn records. The vDataColumn will be transformed.
Parameters#
- pat: str
Regular expression.
Returns#
- vDataFrame
self._parent
Examples#
Let’s begin by importing VerticaPy.
import verticapy as vp
Let’s generate a small dataset using the following data:
data = vp.vDataFrame( { "rollno": ['1', '2', '3', '4'], "subjects": [ 'English, Math', 'English, Math, Computer', 'Math, Computer, Science', 'Math, Science', ], } )
Let’s retrieve the second subject.
data["subjects"].str_contains(pat = "English").select( [ "rollno", "subjects as has_english", ] )
AbcrollnoVarchar(1)100%010has_englishBoolean100%1 1 ✅ 2 2 ✅ 3 3 ❌ 4 4 ❌ See also
vDataFrame.
str_count()
: Counts occurrences matching the regular expression.vDataFrame.
str_extract()
: Extracts the Regular Expression.vDataFrame.
str_replace()
: Replaces the Regular Expression.vDataFrame.
str_slice()
: Slices the Regular Expression.