pyspark.pandas.Index.is_all_dates

property Index. is_all_dates

返回索引的所有数据类型是否为日期时间。 请记住,由于 pandas-on-Spark 不支持索引中的多种数据类型, 因此如果任何数据类型是日期时间,则返回 True。

自版本3.4.0起已弃用。

示例

>>> from datetime import datetime
>>> idx = ps.Index([datetime(2019, 1, 1, 0, 0, 0), datetime(2019, 2, 3, 0, 0, 0)])
>>> idx
DatetimeIndex(['2019-01-01', '2019-02-03'], dtype='datetime64[ns]', freq=None)
>>> idx.is_all_dates
True
>>> idx = ps.Index([datetime(2019, 1, 1, 0, 0, 0), None])
>>> idx
DatetimeIndex(['2019-01-01', 'NaT'], dtype='datetime64[ns]', freq=None)
>>> idx.is_all_dates
True
>>> idx = ps.Index([0, 1, 2])
>>> idx  
Int64Index([0, 1, 2], dtype='int64')
>>> idx.is_all_dates
False