pandera.engines.pandas_engine.DateTime

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

可能时区感知的日期时间的语义表示。

对于不带时区的日期时间使用 np.dtype("datetime64[ns]"),对于带时区的日期时间使用 pandas.DatetimeTZDtype

属性

auto_coerce

在所有情况下是否强制转换为True

continuous

数字数据类型是否是连续的。

type

由数据类型封装的原生 pandas 数据类型。

tz

时区。

unit

日期时间数据的精度。

to_datetime_kwargs

传递给 pandas.to_datetime() 用于强制转换的任何其他参数。

tz_localize_kwargs

传递给 pandas.Series.dt.tz_localize() 用于强制转换的关键字参数。

方法

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

检查 pandera DataType 是否等价。

Parameters:
  • pandera_dtype (DataType) – 预期 DataType

  • data_container (Union[Series, DataFrame, None]) – 数据容器,用于需要实际数据进行验证的数据类型。

Return type:

Union[bool, Iterable[bool]]

Returns:

布尔标量或布尔标量的可迭代对象,指示哪些元素通过了检查。

coerce(data_container)[source]

纯强制转换而不捕获异常。

Return type:

Union[Series, DataFrame]

coerce_value(value)[source]

将值强制转换为指定的日期时间类型。

Return type:

Any

classmethod from_parametrized_dtype(pd_dtype)[source]

将一个 pandas.DatetimeTZDtype 转换为 Pandera pandera.engines.pandas_engine.DateTime

try_coerce(data_container)[source]

强制数据容器转换为数据类型, 如果强制转换失败,则引发 ParserError :raises: ParserError: 如果强制转换失败

Return type:

Union[Series, DataFrame]

__call__(data_container)[source]

将数据容器强制转换为数据类型。