Skip to main content
`Ctrl`+`K`

# pandas.PeriodIndex.daysinmonth

property PeriodIndex.daysinmonth

  The number of days in the month.

  Returns the total number of days in the month of each period, accounting for leap years.

  See also

  `PeriodIndex.day`

    The days of the period.

  `PeriodIndex.days_in_month`

    The number of days in the month.

  `PeriodIndex.daysinmonth`

    The number of days in the month.

  `PeriodIndex.month`

    The month as January=1, December=12.

  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')