pandas.DatetimeIndex.is_year_end#

property DatetimeIndex.is_year_end#

指示该日期是否为一年的最后一天。

退货
系列或日期索引

与具有布尔值的原始数据相同的类型。系列将具有相同的名称和索引。DatetimeIndex将具有相同的名称。

参见

is_year_start

表示年初的类似属性。

示例

此方法在具有DateTime值的系列中可用 .dt 访问器,并直接在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])