Skip to main content
GuideTutorialsConfigure data integration workflows within a running Tabsdata server.API ReferenceRelease Notes
Version: 1.9.1

TableFrame.assert_has_cols

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
cols

The expected column name(s). Can be a string or a list of strings.

parameter
exact

If 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)