vastorbit.VastColumn.str_count¶
- VastColumn.str_count(pat: str) VastFrame¶
Computes the number of matches for the regular expression in each record of the VastColumn. The VastColumn will be transformed.
- Parameters:
pat (str) – regular expression.
- Returns:
self._parent
- Return type:
Examples
Let’s begin by importing vastorbit.
import vastorbit as vo
Let’s generate a small dataset using the following data:
data = vo.VastFrame( { "rollno": ['1', '2', '3', '4'], "subjects": [ 'English, Math', 'English, Math, Computer', 'Math, Computer, Science', 'Math, Science', ], } )
Let’s count number of times “English” appears in “subjects” VastColumn.
data["subjects"].str_count(pat = "English").select( [ "rollno", "subjects as english_count", ] )
AbcrollnoVarchar(1)123english_countBigint1 2 1 2 3 0 3 4 0 4 1 1 Rows: 1-4 | Columns: 2See also
VastFrame.str_contains(): Validates the regular expression.VastFrame.str_extract(): Extracts the Regular Expression.VastFrame.str_replace(): Replaces the Regular Expression.VastFrame.str_slice(): Slices the Regular Expression.