TableFrame.assert_has_cols
methodView source ↗
def assert_has_cols(cols: str | list[str], exact: bool | None = False)
Categories: tableframe
Ensures that the (non-system) columns in the TableFrame match the expected columns.
Raises an exception if the expectation is not met.
If exact is True, the check verifies that the TableFrame contains exactly the
expected columns, with no extra or missing ones.
Parameters
parameter
colsThe expected column name(s). Can be a string or a list of strings.
parameter
exactIf True, checks that the TableFrame contains exactly the specified columns.
Raises
ValueError: If expected columns are missing or unexpected columns are present in the TableFrame.
Examples
>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>> tf.assert_has_cols("a")
>>> tf.assert_has_cols(["a", "b"], exact=True)