当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python pandas.Series.dt.is_year_end用法及代码示例


用法:

Series.dt.is_year_end

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

返回

系列或日期时间索引

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

例子

此方法在具有日期时间值的系列上可用,位于 .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])

相关用法


注:本文由纯净天空筛选整理自pandas.pydata.org大神的英文原创作品 pandas.Series.dt.is_year_end。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。