column_string_operation

grizli.utils.column_string_operation(col, test, method='contains', logical='or')[source]

Analogous to str.contains but 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 test is a string, or list of strings, then run the string method on each entry of col with test as the argument or each element of the test list as arguments.

If test is None, run method on each entry with no arguments, e.g., ‘upper’.

If test is a slice, 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 test is 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 of bool or string.