pandas.DatetimeIndex.is_month_start#

property DatetimeIndex.is_month_start[源代码]#

指示日期是否为月份的第一天。

Returns:
Series 或 array

对于 Series,返回一个布尔值 Series。对于 DatetimeIndex,返回一个布尔数组。

参见

is_month_start

返回一个布尔值,指示日期是否为当月的第一天。

is_month_end

返回一个布尔值,指示日期是否为当月的最后一天。

Examples

此方法可通过 .dt 访问器在具有 datetime 值的 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])