tabsdata.tableframe.selectors.matches#
- matches(pattern: str) SelectorProxy [source]#
Select all columns whose names match a regular expression pattern.
- Parameters:
pattern – A regular expression pattern to match against column names.
Example
>>> import tabsdata.tableframe as td_tf >>> >>> tf = td_tf.TableFrame({ ... "ColA": [1, 2, 3, 4, 5, 6, 7, 8], ... "ColB": [8, 7, 6, 5, 4, 3, 2, 1], ... "Data2024": [10, 20, 30, 40, 50, 60, 70, 80], ... "Meta": ["a", "b", "c", "d", "e", "f", "g", "h"] ... })
Original: ┌──────┬──────┬──────────┬──────┐ │ ColA ┆ ColB ┆ Data2024 ┆ Meta │ │ — ┆ — ┆ — ┆ — │ │ i64 ┆ i64 ┆ i64 ┆ str │ ╞══════╪══════╪══════════╪══════╡ │ 1 ┆ 8 ┆ 10 ┆ “a” │ │ 2 ┆ 7 ┆ 20 ┆ “b” │ │ 3 ┆ 6 ┆ 30 ┆ “c” │ │ 4 ┆ 5 ┆ 40 ┆ “d” │ │ 5 ┆ 4 ┆ 50 ┆ “e” │ │ 6 ┆ 3 ┆ 60 ┆ “f” │ │ 7 ┆ 2 ┆ 70 ┆ “g” │ │ 8 ┆ 1 ┆ 80 ┆ “h” │ └──────┴──────┴──────────┴──────┘
>>> tf.select(td_tf.selectors.matches(r"^Col"))
Selected: ┌──────┬──────┐ │ ColA ┆ ColB │ │ — ┆ — │ │ i64 ┆ i64 │ ╞══════╪══════╡ │ 1 ┆ 8 │ │ 2 ┆ 7 │ │ 3 ┆ 6 │ │ 4 ┆ 5 │ │ 5 ┆ 4 │ │ 6 ┆ 3 │ │ 7 ┆ 2 │ │ 8 ┆ 1 │ └──────┴──────┘