pandas.DatetimeIndex.is_month_start#

property DatetimeIndex.is_month_start#

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

退货
系列或阵列

对于系列,返回具有布尔值的系列。对于DatetimeIndex,返回布尔数组。

参见

is_month_start

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

is_month_end

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

示例

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