tabsdata.tableframe.selectors.starts_with#

starts_with(*prefix: str) SelectorProxy[source]#

Select all columns whose names start with any of the given prefixes.

Parameters:

prefix – One or more string prefixes to match at the beginning of column names.

Example

>>> import tabsdata.tableframe as td_tf
>>>
>>> tf = td_tf.TableFrame({
...     "PreName": ["Alice", "Bob", "Caro", "Dan", "Eve", "Fay", "Gus", "Hana"],
...     "PreScore": [90, 85, 78, 92, 88, 91, 84, 89],
...     "Id": [1, 2, 3, 4, 5, 6, 7, 8],
...     "Note": ["A", "B", "C", "D", "E", "F", "G", "H"]
... })

Original: ┌──────────┬──────────┬────┬──────┐ │ PreName ┆ PreScore ┆ Id ┆ Note │ │ — ┆ — ┆ —┆ — │ │ str ┆ i64 ┆ i64┆ str │ ╞══════════╪══════════╪════╪══════╡ │ “Alice” ┆ 90 ┆ 1 ┆ “A” │ │ “Bob” ┆ 85 ┆ 2 ┆ “B” │ │ “Caro” ┆ 78 ┆ 3 ┆ “C” │ │ “Dan” ┆ 92 ┆ 4 ┆ “D” │ │ “Eve” ┆ 88 ┆ 5 ┆ “E” │ │ “Fay” ┆ 91 ┆ 6 ┆ “F” │ │ “Gus” ┆ 84 ┆ 7 ┆ “G” │ │ “Hana” ┆ 89 ┆ 8 ┆ “H” │ └──────────┴──────────┴────┴──────┘

>>> tf.select(td_tf.selectors.starts_with("Pre"))

Selected: ┌──────────┬──────────┐ │ PreName ┆ PreScore │ │ — ┆ — │ │ str ┆ i64 │ ╞══════════╪══════════╡ │ “Alice” ┆ 90 │ │ “Bob” ┆ 85 │ │ “Caro” ┆ 78 │ │ “Dan” ┆ 92 │ │ “Eve” ┆ 88 │ │ “Fay” ┆ 91 │ │ “Gus” ┆ 84 │ │ “Hana” ┆ 89 │ └──────────┴──────────┘