pandas.PeriodIndex.days_in_month — pandas 2.2.3 documentation (original) (raw)

property PeriodIndex.days_in_month[source]#

The number of days in the month.

Examples

For Series:

period = pd.period_range('2020-1-1 00:00', '2020-3-1 00:00', freq='M') s = pd.Series(period) s 0 2020-01 1 2020-02 2 2020-03 dtype: period[M] s.dt.days_in_month 0 31 1 29 2 31 dtype: int64

For PeriodIndex:

idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M") idx.days_in_month # It can be also entered as daysinmonth Index([31, 28, 31], dtype='int64')