tabsdata.tableframe.selectors.contains#

contains(*substring: str) SelectorProxy[source]#

Select all columns whose names contain one or more of the given substrings.

Parameters:

substring – One or more substrings to search for in column names.

Example

>>> import tabsdata.tableframe as td_tf
>>>
>>> tf = td_tf.TableFrame({
...     "UserId": [1, 2, 3, 4, 5, 6, 7, 8],
...     "UserName": ["A", "B", "C", "D", "E", "F", "G", "H"],
...     "Age": [22, 34, 28, 45, 30, 33, 26, 29],
...     "Email": ["a@x", "b@x", "c@x", "d@x", "e@x", "f@x", "g@x", "h@x"]
... })

Original: ┌────────┬──────────┬─────┬───────┐ │ UserId ┆ UserName ┆ Age ┆ Email │ ├────────┼──────────┼─────┼───────┤ │ 1 ┆ “A” ┆ 22 ┆ “a@x” │ │ 2 ┆ “B” ┆ 34 ┆ “b@x” │ │ 3 ┆ “C” ┆ 28 ┆ “c@x” │ │ 4 ┆ “D” ┆ 45 ┆ “d@x” │ │ 5 ┆ “E” ┆ 30 ┆ “e@x” │ │ 6 ┆ “F” ┆ 33 ┆ “f@x” │ │ 7 ┆ “G” ┆ 26 ┆ “g@x” │ │ 8 ┆ “H” ┆ 29 ┆ “h@x” │ └────────┴──────────┴─────┴───────┘

>>> tf.select(td_tf.selectors.contains("Name", "Id"))

Selected: ┌────────┬──────────┐ │ UserId ┆ UserName │ ├────────┼──────────┤ │ 1 ┆ “A” │ │ 2 ┆ “B” │ │ 3 ┆ “C” │ │ 4 ┆ “D” │ │ 5 ┆ “E” │ │ 6 ┆ “F” │ │ 7 ┆ “G” │ │ 8 ┆ “H” │ └────────┴──────────┘