pandera.extensions#

Extensions module, for backwards compatibility.

class pandera.extensions.CheckType(value)[source]#

Bases: enum.Enum

Check types for registered check methods.

VECTORIZED = 1#

Check applied to a Series or DataFrame

ELEMENT_WISE = 2#

Check applied to an element of a Series or DataFrame

GROUPBY = 3#

Check applied to dictionary of Series or DataFrames.

pandera.extensions.generate_check_annotations(check_cls, statistics_params)[source]#

Generates a check type annotations from check statistics.

Return type

Dict[str, Type]

pandera.extensions.generate_check_signature(check_cls, sig, statistics_params)[source]#

Generates a check signature from check statistics.

Return type

Signature

pandera.extensions.modify_check_fn_doc(doc)[source]#

Adds

Return type

str

pandera.extensions.register_check(fn=None, pre_init_hook=None, aliases=None, strategy=None, error=None, check_cls=<class 'pandera.core.checks.Check'>, samples_kwtypes=None, **outer_kwargs)[source]#

Register a check method to the Check namespace.

This is the primary way for extending the Check api to define additional built-in checks.

pandera.extensions.register_check_method(check_fn=None, *, statistics=None, supported_types=(<class 'pandas.core.frame.DataFrame'>, <class 'pandas.core.series.Series'>), check_type='vectorized', strategy=None)[source]#

Registers a function as a Check method.

See the user guide for more details.

Warning

This is the legacy method for registering check methods. Use the register_check() decorator instead.

Parameters
  • check_fn – check function to register. The function should take one positional argument for the object to validate and additional keyword-only arguments for the check statistics.

  • statistics (Optional[List[str]]) – list of keyword-only arguments in the check_fn, which serve as the statistics needed to serialize/de-serialize the check and generate data if a strategy function is provided.

  • supported_types (Union[type, Tuple, List]) – the pandas type(s) supported by the check function. Valid values are pd.DataFrame, pd.Series, or a list/tuple of (pa.DataFrame, pa.Series) if both types are supported.

  • check_type (Union[CheckType, str]) –

    the expected input of the check function. Valid values are CheckType enums or {"vectorized", "element_wise", "groupby"}. The input signature of check_fn is determined by this argument:

    • if vectorized, the first positional argument of check_fn should be one of the supported_types.

    • if element_wise, the first positional argument of check_fn should be a single scalar element in the pandas Series or DataFrame.

    • if groupby, the first positional argument of check_fn should be a dictionary mapping group names to subsets of the Series or DataFrame.

  • strategy – data-generation strategy associated with the check function.

Returns

register check function wrapper.

pandera.extensions.register_hypothesis(samples_kwtypes=None, **kwargs)[source]#

Register a new hypothesis.

pandera.extensions.update_check_fn_proxy(check_cls, check_function_proxy, fn, fn_sig, statistics_params)[source]#

Manually update the signature of check_function so that docstring matches original function’s signature, but includes **kwargs, etc.