column_string_operation¶
- grizli.utils.column_string_operation(col, test, method='contains', logical='or')[source]¶
Analogous to
str.containsbut for table column.- Parameters
- coliterable list of strings
List of strings to test. Anything iterable, e.g., list or
Column.- teststr, list of strings, None, or slice
If
testis a string, or list of strings, then run the stringmethodon each entry ofcolwithtestas the argument or each element of thetestlist as arguments.If
testis None, runmethodon each entry with no arguments, e.g., ‘upper’.If
testis aslice, return sliced strings for each entry.- methodstr
String method to apply to each entry of
col. E.g., ‘contains’, ‘startswith’, ‘endswith’, ‘index’.- logical[‘or’,’and’,’not’]
Logical test to use when
testis a list of strings. For example, if you want to test if the column has values that match either ‘value1’ or ‘value2’, then run with>>> res = column_to_string_operation(col, ['value1','value2'], method='contains', logical='or')
- Returns
- resultlist
List of iterated results on the entries of
col, e.g., list ofboolorstring.