pandas.Series.dt.is_year_end #
- 系列.dt。is_year_end [来源] #
指示日期是否是一年中的最后一天。
- 返回:
- 系列或日期时间索引
与带有布尔值的原始数据类型相同。系列将具有相同的名称和索引。 DatetimeIndex 将具有相同的名称。
也可以看看
is_year_start
类似的属性表示年份的开始。
例子
此方法可在
.dt
访问器下具有日期时间值的 Series 上使用,也可直接在 DatetimeIndex 上使用。>>> dates = pd.Series(pd.date_range("2017-12-30", periods=3)) >>> dates 0 2017-12-30 1 2017-12-31 2 2018-01-01 dtype: datetime64[ns]
>>> dates.dt.is_year_end 0 False 1 True 2 False dtype: bool
>>> idx = pd.date_range("2017-12-30", periods=3) >>> idx DatetimeIndex(['2017-12-30', '2017-12-31', '2018-01-01'], dtype='datetime64[ns]', freq='D')
>>> idx.is_year_end array([False, True, False])