Skip to main content
`Ctrl`+`K`

# pandas.Period.asfreq

Period.asfreq(freq, how='E')

  Convert Period to desired frequency, at the start or end of the interval.

  Parameters:
    freq str, DateOffset

      The target frequency to convert the Period object to. If a string is provided, it must be a valid period alias.

    how{‘E’, ‘S’, ‘end’, ‘start’}, default ‘end’

      Specifies whether to align the period to the start or end of the interval: - ‘E’ or ‘end’: Align to the end of the interval. - ‘S’ or ‘start’: Align to the start of the interval.

  Returns:
    Period Period object with the specified frequency, aligned to the parameter.

  See also

  `Period.end_time`

    Return the end Timestamp.

  `Period.start_time`

    Return the start Timestamp.

  `Period.dayofyear`

    Return the day of the year.

  `Period.dayofweek`

    Return the day of the week.

  Examples

  Convert a daily period to an hourly period, aligning to the end of the day:

      >>> period = pd.Period('2023-01-01', freq='D')
      >>> period.asfreq('h')
      Period('2023-01-01 23:00', 'h')

  Convert a monthly period to a daily period, aligning to the start of the month:

      >>> period = pd.Period('2023-01', freq='M')
      >>> period.asfreq('D', how='start')
      Period('2023-01-01', 'D')

  Convert a yearly period to a monthly period, aligning to the last month:

      >>> period = pd.Period('2023', freq='Y')
      >>> period.asfreq('M', how='end')
      Period('2023-12', 'M')

  Convert a monthly period to an hourly period, aligning to the first day of the month:

      >>> period = pd.Period('2023-01', freq='M')
      >>> period.asfreq('h', how='start')
      Period('2023-01-01 00:00', 'H')

  Convert a weekly period to a daily period, aligning to the last day of the week:

      >>> period = pd.Period('2023-08-01', freq='W')
      >>> period.asfreq('D', how='end')
      Period('2023-08-04', 'D')