pandera.engines.pandas_engine.DateTime

class pandera.engines.pandas_engine.DateTime(to_datetime_kwargs=<factory>, unit='ns', tz=None, time_zone_agnostic=False, tz_localize_kwargs=<factory>)[source]

Semantic representation of a potentially timezone-aware datetime.

Uses np.dtype("datetime64[ns]") for non-timezone aware datetimes and pandas.DatetimeTZDtype for timezone-aware datetimes.

Attributes

auto_coerce

Whether to force coerce to be True in all cases

continuous

Whether the number data type is continuous.

time_zone_agnostic

A flag indicating whether the datetime data should be handled flexibly with respect to timezones.

type

Native pandas dtype boxed by the data type.

tz

The timezone.

unit

The precision of the datetime data.

to_datetime_kwargs

Any additional kwargs passed to pandas.to_datetime() for coercion.

tz_localize_kwargs

Keyword arguments passed to pandas.Series.dt.tz_localize() for coercion.

Methods

__init__(to_datetime_kwargs=<factory>, unit='ns', tz=None, time_zone_agnostic=False, tz_localize_kwargs=<factory>)[source]
check(pandera_dtype, data_container=None)[source]

Check that pandera DataType are equivalent.

Parameters:
  • pandera_dtype (DataType) – Expected DataType.

  • data_container (Union[Series, DataFrame, None]) – Data container, used by data types that require the actual data for validation.

Return type:

Union[bool, Iterable[bool]]

Returns:

boolean scalar or iterable of boolean scalars, indicating which elements passed the check.

coerce(data_container)[source]

Pure coerce without catching exceptions.

Return type:

Union[Series, DataFrame]

coerce_value(value)[source]

Coerce an value to specified datatime type.

Return type:

Any

classmethod from_parametrized_dtype(pd_dtype)[source]

Convert a pandas.DatetimeTZDtype to a Pandera pandera.engines.pandas_engine.DateTime.

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]

__call__(data_container)[source]

Coerce data container to the data type.