table_enforcer package

Submodules

table_enforcer.errors module

Provide error classes.

exception table_enforcer.errors.NotImplementedYet(msg=None)[source]

Bases: NotImplementedError, table_enforcer.errors.TableEnforcerError

Raise when a section of code that has been left for another time is asked to execute.

__init__(msg=None)[source]

Set up the Exception.

exception table_enforcer.errors.TableEnforcerError[source]

Bases: Exception

Base error class.

exception table_enforcer.errors.ValidationError[source]

Bases: table_enforcer.errors.TableEnforcerError

Raise when a validation/sanity check comes back with unexpected value.

table_enforcer.main_classes module

Main module.

class table_enforcer.main_classes.Enforcer(columns)[source]

Bases: object

Class to define table definitions.

__init__(columns)[source]

Initialize an enforcer instance.

make_validations(table: pandas.core.frame.DataFrame) → munch.Munch[source]

Return a dict-like object containing dataframes of which tests passed/failed for each column.

recode(table: pandas.core.frame.DataFrame) → pandas.core.frame.DataFrame[source]

Return a fully recoded dataframe.

validate(table: pandas.core.frame.DataFrame, recode: bool = False) → bool[source]

Return True if all validation tests pass: False otherwise.

class table_enforcer.main_classes.Column(name: str, dtype: type, unique: bool, validators: typing.List[typing.Callable[[pandas.core.series.Series], pandas.core.frame.DataFrame]], recoders: typing.List[typing.Callable[[pandas.core.series.Series], pandas.core.series.Series]]) → None[source]

Bases: object

Class representing a single table column.

__init__(name: str, dtype: type, unique: bool, validators: typing.List[typing.Callable[[pandas.core.series.Series], pandas.core.frame.DataFrame]], recoders: typing.List[typing.Callable[[pandas.core.series.Series], pandas.core.series.Series]]) → None[source]

Construct a new Column object.

_dict_of_funcs(funcs: list) → pandas.core.series.Series[source]

Return a pd.Series of functions with index derived from the function name.

_validate_series_dtype(series: pandas.core.series.Series) → pandas.core.series.Series[source]

Validate that the series data is the correct dtype.

recode(table: pandas.core.frame.DataFrame) → pandas.core.series.Series[source]

Pass the appropriate column data in table through each recoder function in series and return the final result.

validate(table: pandas.core.frame.DataFrame, recode: bool = False) → pandas.core.frame.DataFrame[source]

Return a dataframe of validation results for the correct column in table vs the vector of validators.

Module contents

Top-level package for Table Enforcer.