validation

The module contains functionality for a static type validation of pandas dataframes.

class alphadia.validation.base.Optional(name, type)[source]

Bases: Property

Optional property

__init__(name, type)[source]

Optional property

Parameters:
  • name (str) – Name of the property

  • type (type) – Type of the property

class alphadia.validation.base.Property(name, type)[source]

Bases: object

Column property base class

__init__(name, type)[source]

Base class for all properties

Parameters:
  • name (str) – Name of the property

  • type (type) – Type of the property

class alphadia.validation.base.Required(name, type)[source]

Bases: Property

Required property

__init__(name, type)[source]

Required property

Parameters:
  • name (str) – Name of the property

  • type (type) – Type of the property

class alphadia.validation.base.Schema(name, properties)[source]

Bases: object

__init__(name, properties)[source]

Schema for validating dataframes

Parameters:
  • name (str) – Name of the schema

  • properties (list) – List of Property objects

docstring() str[source]

Automatically generate a docstring for the schema.

Returns:

Docstring for the schema

Return type:

str

validate(df: DataFrame, logging: bool = True, warn_on_critical_values: bool = False) None[source]

Validates the dataframe.

Parameters:
  • df (pd.DataFrame) – Dataframe to validate

  • logging (bool) – If True, log the validation results. Defaults to True.

  • warn_on_critical_values (bool) – If True, warn on critical values like NaN and Inf in the dataframe. Defaults to False.

Raises:

ValueError – If validation fails.