Skip to main content
`Ctrl`+`K`

# pandas.PeriodIndex.freqstr

property PeriodIndex.freqstr

  Return the frequency object as a string if it’s set, otherwise None.

  This property returns a string representation of the frequency (e.g., `'D'` for daily, `'h'` for hourly) when one has been set on the index, either explicitly or via inference.

  See also

  `DatetimeIndex.inferred_freq`

    Returns a string representing a frequency generated by infer_freq.

  Examples

  For DatetimeIndex:

      >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00"], freq="D")
      >>> idx.freqstr
      'D'

  The frequency can be inferred if there are more than 2 points:

      >>> idx = pd.DatetimeIndex(
      ...     ["2018-01-01", "2018-01-03", "2018-01-05"], freq="infer"
      ... )
      >>> idx.freqstr
      '2D'

  For PeriodIndex:

      >>> idx = pd.PeriodIndex(["2023-1", "2023-2", "2023-3"], freq="M")
      >>> idx.freqstr
      'M'