Schema.is_valid#
- classmethod Schema.is_valid(
- df: DataFrame | LazyFrame,
- /,
- *,
- cast: bool = False,
Check whether a data frame satisfies the schema.
This method has two major differences to
validate():It always collects the input to eagerly evaluate validity and return a boolean value.
It does not raise any of the documented exceptions for
validate()and instead returns a value ofFalse. Note that it still raises an exception if a lazy frame is provided as input and any logic prior to the validation causes an exception.
- Parameters:
df – The data frame to check for validity.
cast – Whether columns with a wrong data type in the input data frame are cast to the schema’s defined data type before running validation. If set to
False, a wrong data type will result in a return value ofFalse.
- Returns:
Whether the provided dataframe can be validated with this schema.
Notes
If you want to customize the engine being used for collecting the result within this method, consider wrapping the call in a context manager that sets the
engine_affinityin thepolars.Config.