pandera.engines.pandas_engine.PythonNamedTuple

class pandera.engines.pandas_engine.PythonNamedTuple(special_type=None)[source]

A datatype to support python generics.

Attributes

auto_coerce

Whether to force coerce to be True in all cases

coercion_model

continuous

Whether the number data type is continuous.

generic_type

special_type

Methods

__init__(special_type=None)[source]
check(pandera_dtype, data_container=None)[source]

Check that data container has the expected type.

Return type:

Union[bool, Iterable[bool]]

coerce(data_container)[source]

Coerce data container to the specified data type.

Return type:

Union[Series, DataFrame]

coerce_value(value)[source]

Coerce an value to a particular type.

Return type:

Any

try_coerce(data_container)[source]

Coerce data container to the data type, raises a ParserError if the coercion fails :raises: ParserError: if coercion fails

Return type:

Union[Series, DataFrame]

type(fields=None, /, **kwargs)[source]

Typed version of namedtuple.

Usage:

class Employee(NamedTuple):
    name: str
    id: int

This is equivalent to:

Employee = collections.namedtuple('Employee', ['name', 'id'])

The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) An alternative equivalent functional syntax is also accepted:

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
__call__(data_container)[source]

Coerce data container to the data type.