pandas.DatetimeIndex.is_month_end #
- 属性 DatetimeIndex。is_month_end [来源] #
指示日期是否是该月的最后一天。
- 返回:
- 系列或阵列
对于系列,返回带有布尔值的系列。对于 DatetimeIndex,返回一个布尔数组。
也可以看看
is_month_start
返回一个布尔值,指示日期是否为该月的第一天。
is_month_end
返回一个布尔值,指示日期是否是该月的最后一天。
例子
此方法可在
.dt
访问器下具有日期时间值的 Series 上使用,也可直接在 DatetimeIndex 上使用。>>> s = pd.Series(pd.date_range("2018-02-27", periods=3)) >>> s 0 2018-02-27 1 2018-02-28 2 2018-03-01 dtype: datetime64[ns] >>> s.dt.is_month_start 0 False 1 False 2 True dtype: bool >>> s.dt.is_month_end 0 False 1 True 2 False dtype: bool
>>> idx = pd.date_range("2018-02-27", periods=3) >>> idx.is_month_start array([False, False, True]) >>> idx.is_month_end array([False, True, False])