TableFrame.has_cols
methodView source ↗
def has_cols(
cols: str | list[str],
exact: bool | None = False,
) -> (bool, set[str], set[str])
Categories: tableframe
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
parameter
colsThe column name(s) to verify. Can be a string or a list of strings.
parameter
exactIf True, checks that the TableFrame contains exactly the specified columns.
Returns
tuple[bool, set[str], set[str]]:
- A boolean indicating whether the check was successful.
- A set of columns in
colsmissing in the TableFrame. - A set of columns in the TableFrame missing in
cols.
Examples
>>> 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, {}, {})