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
- try_coerce(data_container)[source]¶
Coerce data container to the data type, raises a
ParserError
if 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)])