Validate scheme¶
validate
¶
Validation utilities for weighting schemes.
This module provides functions to validate survey dataframes against weighting schemes before applying weights. Validation checks include column existence, missing values, and category mismatches between the data and scheme definitions.
validate_scheme_dict(df, scheme, raise_error=True)
¶
Validate a dataframe against a scheme dictionary.
Checks if Data matches the Scheme (Columns, Categories, NaNs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The survey dataframe to check |
required |
scheme
|
SchemeDict
|
The dictionary defining the weighting scheme |
required |
raise_error
|
bool
|
If True, raises a ValueError on the first Critical issue found. If False, returns a DataFrame report of all issues |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame or None
|
DataFrame report of all issues if raise_error=False, None otherwise |
validate_scheme(df, scheme, raise_error=True)
¶
Validate a dataframe against a Rim scheme object.
Checks for Columns, NaNs, and Category mismatches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The survey dataframe to check |
required |
scheme
|
Rim
|
The Rim scheme object defining the weighting scheme |
required |
raise_error
|
bool
|
If True, raises a ValueError on the first Critical issue found. If False, returns a DataFrame report of all issues |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame or None
|
DataFrame report of all issues if raise_error=False, None otherwise |