tabsdata.tableframe.lazyframe.frame.TableFrame.has_cols#

TableFrame.has_cols(cols: str | list[str], exact: bool | None = False) Tuple[bool, set[str], set[str]][source]#

Verifies the presence of (non-system) columns in the TableFrame.

If exact is True, the check ensures that the TableFrame contains exactly the specified columns (excluding system columns), with no extras or omissions.

Parameters:
  • cols – The column name(s) to verify. Can be a string or a list of strings.

  • exact – If True, checks that the TableFrame contains exactly the specified columns.

Returns:

  • A boolean indicating whether the check was successful.

  • A set of columns in cols missing in the TableFrame.

  • A set of columns in the TableFrame missing in cols.

Return type:

tuple[bool, set[str], set[str]]

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ i64  │
╞══════╪══════╡
│ A    ┆ 1    │
└──────┴──────┘
>>>
>>> tf.has_cols("a")
>>>
(True, {}, {"b"})
>>>
>>> tf.has_cols(["a", "c", "d"])
>>>
(False, {"c", "d"}, {"b"})
>>>
>>> tf.has_cols("a", exact=True)
>>>
(False, {}, {"b"})
>>>
>>> tf.has_cols(["a", "b"], exact=True)
>>>
(True, {}, {})