pandera.engines.pandas_engine.PythonNamedTupleΒΆ
- class pandera.engines.pandas_engine.PythonNamedTuple(special_type=None)[source]ΒΆ
A datatype to support python generics.
Attributes
auto_coerceWhether to force coerce to be True in all cases
coercion_modelcontinuousWhether the number data type is continuous.
generic_typespecial_typeMethods
- check(pandera_dtype, data_container=None)[source]ΒΆ
Check that data container has the expected type.
- try_coerce(data_container)[source]ΒΆ
Coerce data container to the data type, raises a
ParserErrorif the coercion fails :raises:ParserError: if coercion fails
- 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)])