deirokay.parser.treaters.builtin.numeric_treater.NumericTreater

class deirokay.parser.treaters.builtin.numeric_treater.NumericTreater(thousand_sep: Optional[str] = None, **kwargs)[source]

Bases: Validator

Base class for numeric treaters

Parameters

thousand_sep (Optional[str], optional) – Character to use as thousand separator, by default None

Methods

attach_backend

Generate a subclass that concretizes multibackend backend methods into their intended name.

get_backend

Get current active backend for this class.

register_backend_method

Proxy for register_backend_method to register an existing function as a backend-specific method.

serialize

Create a Deirokay-compatible serializable object that can be serialized (in JSON or YAML formats) and parsed back by Deirokay treaters.

treat

Treat a raw Series to match data expectations for parsing and formatting.

Attributes

DISPLAY_DUPL_INDICES_LIMIT

DISPLAY_NULL_INDICES_LIMIT

supported_backends

Backends supported by this resource.

supported_dtype

DType treated by this treater.

supported_primitives

List of primitives supported by this treater.

DISPLAY_DUPL_INDICES_LIMIT = 10
DISPLAY_NULL_INDICES_LIMIT = 30
__call__(series: DeirokayDataSeries) DeirokayDataSeries

Proxy for treat.

classmethod __post_attach_backend__()

This classmethod can be optionally overwritten to serve as a callback function for when the attach_backend() method is called.

classmethod attach_backend(backend: Backend) Type[_AnyMultiBackendClass]

Generate a subclass that concretizes multibackend backend methods into their intended name. The methods marked with the given backend will compose the returned class.

Parameters
  • cls (type) – Class to be subclassed with the given backend.

  • backend (Backend) – Backend to be selected.

Returns

Subclass of the current class with methods filtered for the given backend.

Return type

Type[MultiBackendMixin]

classmethod get_backend() Backend

Get current active backend for this class.

Returns

The current active backend.

Return type

Backend

Raises

InvalidBackend – Backend not set or not a valid execution class.

classmethod register_backend_method(alias_for: str, func: Callable[[...], Any], backend: Backend) None

Proxy for register_backend_method to register an existing function as a backend-specific method.

Parameters
  • alias_for (str) – The name of the method to be substituted with a backend-specific version.

  • func (AnyCallable) – Existing function to be registered as a method.

  • backend (Backend) – Backend for the method.

static serialize(series: DeirokayDataSeries) Dict[Literal['values', 'parser'], Union[List, Dict]]

Create a Deirokay-compatible serializable object that can be serialized (in JSON or YAML formats) and parsed back by Deirokay treaters. This method is useful when generating validation documents that embed Deirokay-compatible user data. The output format is a Python dict containing two keys: - values: list of values as Python object. - parser: Deirokay options to parse the data. (See more: deirokay.parser.get_treater_instance).

Parameters

series (DeirokayDataSeries) – Series data to be serialized.

Returns

A Python dict containing the keys values and parser.

Return type

dict

supported_backends: List[Backend] = [<Backend.PANDAS: 'pandas'>, <Backend.DASK: 'dask'>]

Backends supported by this resource.

Type

List[Backend]

supported_dtype: Optional[DTypes] = None

DType treated by this treater.

Type

Optional[DTypes]

supported_primitives: List[Any] = []

List of primitives supported by this treater.

Type

List[Any]

treat(series: Iterable) DeirokayDataSeries

Treat a raw Series to match data expectations for parsing and formatting.

Calls the appropriate method for the detected backend

Parameters

series (Iterable) – Raw series to be treated.