prokbert.general_utils.check_expected_columns
- prokbert.general_utils.check_expected_columns(df: DataFrame, expected_columns: list) bool
Checks if a DataFrame contains the expected columns.
- Parameters
df (pd.DataFrame) – The input DataFrame to be checked.
expected_columns (list) – A list of columns that are expected to be present in the DataFrame.
df – pd.DataFrame:
expected_columns – list:
- Returns
True if all expected columns are present in the DataFrame, False otherwise.
- Return type
- Raises
ValueError – If any of the expected columns are not present in the DataFrame.
>>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) >>> check_expected_columns(df, ['A', 'B']) True
>>> check_expected_columns(df, ['A', 'C']) ValueError: The following columns are missing: ['C']