pandas.api.types.is_period_dtype#

pandas.api.types.is_period_dtype(arr_or_dtype)[源代码]#

检查数组或 dtype 是否为 Period dtype。

自 2.2.0 版本弃用: 请改用 isinstance(dtype, pd.Period) 。

Parameters:
arr_or_dtypearray-like or dtype

要检查的类数组或 dtype。

Returns:
boolean

数组或 dtype 是否为 Period dtype。

Examples

>>> from pandas.core.dtypes.common import is_period_dtype
>>> is_period_dtype(object)
False
>>> is_period_dtype(pd.PeriodDtype(freq="D"))
True
>>> is_period_dtype([1, 2, 3])
False
>>> is_period_dtype(pd.Period("2017-01-01"))
False
>>> is_period_dtype(pd.PeriodIndex([], freq="Y"))
True