class_docstr: Immutable ndarray holding ordinal values indicating regular periods in time.
  
  Index keys are boxed to Period objects which carries the metadata (eg,
  frequency information).
  
  Parameters
  ----------
  data : array-like (1d int np.ndarray or PeriodArray), optional
      Optional period-like data to construct index with.
  copy : bool
      Make a copy of input ndarray.
  freq : str or period object, optional
      One of pandas period strings or corresponding objects.
  year : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  month : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  quarter : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  day : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  hour : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  minute : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  second : int, array, or Series, default None
  
      .. deprecated:: 2.2.0
         Use PeriodIndex.from_fields instead.
  dtype : str or PeriodDtype, default None
  
  Attributes
  ----------
  day
  dayofweek
  day_of_week
  dayofyear
  day_of_year
  days_in_month
  daysinmonth
  end_time
  freq
  freqstr
  hour
  is_leap_year
  minute
  month
  quarter
  qyear
  second
  start_time
  week
  weekday
  weekofyear
  year
  
  Methods
  -------
  asfreq
  strftime
  to_timestamp
  from_fields
  from_ordinals
  
  See Also
  --------
  Index : The base pandas Index type.
  Period : Represents a period of time.
  DatetimeIndex : Index with datetime64 data.
  TimedeltaIndex : Index of timedelta64 data.
  period_range : Create a fixed-frequency PeriodIndex.
  
  Examples
  --------
  >>> idx = pd.PeriodIndex.from_fields(year=[2000, 2002], quarter=[1, 3])
  >>> idx
  PeriodIndex(['2000Q1', '2002Q3'], dtype='period[Q-DEC]')
class_docstr_tok: ["Immutable","ndarray","holding","ordinal","values","indicating","regular","periods","in","time",".","Index","keys","are","boxed","to","Period","objects","which","carries","the","metadata","(","eg",",","frequency","information",")",".","Parameters","--","--","--","--","--","data",":","array-like","(","1d","int","np.ndarray","or","PeriodArray",")",",","optional","Optional","period-like","data","to","construct","index","with",".","copy",":","bool","Make","a","copy","of","input","ndarray",".","freq",":","str","or","period","object",",","optional","One","of","pandas","period","strings","or","corresponding","objects",".","year",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","month",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","quarter",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","day",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","hour",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","minute",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","second",":","int",",","array",",","or","Series",",","default","None","..","deprecated",":",":","2.2.0","Use","PeriodIndex.from_fields","instead",".","dtype",":","str","or","PeriodDtype",",","default","None","Attributes","--","--","--","--","--","day","dayofweek","day_of_week","dayofyear","day_of_year","days_in_month","daysinmonth","end_time","freq","freqstr","hour","is_leap_year","minute","month","quarter","qyear","second","start_time","week","weekday","weekofyear","year","Methods","--","--","--","-","asfreq","strftime","to_timestamp","from_fields","from_ordinals","See","Also","--","--","--","--","Index",":","The","base","pandas","Index","type",".","Period",":","Represents","a","period","of","time",".","DatetimeIndex",":","Index","with","datetime64","data",".","TimedeltaIndex",":","Index","of","timedelta64","data",".","period_range",":","Create","a","fixed-frequency","PeriodIndex",".","Examples","--","--","--","--",">",">",">","idx","=","pd.PeriodIndex.from_fields","(","year=","[","2000",",","2002","]",",","quarter=","[","1",",","3","]",")",">",">",">","idx","PeriodIndex","(","[","'2000Q1","'",",","'2002Q3","'","]",",","dtype='period","[","Q-DEC","]","'",")"]
code: def __new__(
      cls,
      data=None,
      ordinal=None,
      freq=None,
      dtype: Dtype | None = None,
      copy: bool = False,
      name: Hashable | None = None,
      **fields,
  ) -> Self:
      valid_field_set = {
          "year",
          "month",
          "day",
          "quarter",
          "hour",
          "minute",
          "second",
      }
  
      refs = None
      if not copy and isinstance(data, (Index, ABCSeries)):
          refs = data._references
  
      if not set(fields).issubset(valid_field_set):
          argument = next(iter(set(fields) - valid_field_set))
          raise TypeError(
              f"__new__() got an unexpected keyword argument {argument}"
          )
      elif len(fields):
          # GH#55960
          warnings.warn(
              "Constructing PeriodIndex from fields is deprecated. Use "
              "PeriodIndex.from_fields instead.",
              FutureWarning,
              stacklevel=find_stack_level(),
          )
  
      if ordinal is not None:
          # GH#55960
          warnings.warn(
              "The 'ordinal' keyword in PeriodIndex is deprecated and will "
              "be removed in a future version. Use PeriodIndex.from_ordinals "
              "instead.",
              FutureWarning,
              stacklevel=find_stack_level(),
          )
  
      name = maybe_extract_name(name, data, cls)
  
      if data is None and ordinal is None:
          # range-based.
          if not fields:
              # test_pickle_compat_construction
              cls._raise_scalar_data_error(None)
          data = cls.from_fields(**fields, freq=freq)._data
          copy = False
  
      elif fields:
          if data is not None:
              raise ValueError("Cannot pass both data and fields")
          raise ValueError("Cannot pass both ordinal and fields")
  
      else:
          freq = validate_dtype_freq(dtype, freq)
  
          # PeriodIndex allow PeriodIndex(period_index, freq=different)
          # Let's not encourage that kind of behavior in PeriodArray.
  
          if freq and isinstance(data, cls) and data.freq != freq:
              # TODO: We can do some of these with no-copy / coercion?
              # e.g. D -> 2D seems to be OK
              data = data.asfreq(freq)
  
          if data is None and ordinal is not None:
              ordinal = np.asarray(ordinal, dtype=np.int64)
              dtype = PeriodDtype(freq)
              data = PeriodArray(ordinal, dtype=dtype)
          elif data is not None and ordinal is not None:
              raise ValueError("Cannot pass both data and ordinal")
          else:
              # don't pass copy here, since we copy later.
              data = period_array(data=data, freq=freq)
  
      if copy:
          data = data.copy()
  
      return cls._simple_new(data, name=name, refs=refs)
  
imports: from __future__ import annotations
  from datetime import datetime, timedelta
  from typing import TYPE_CHECKING
  import warnings
  import numpy
  from pandas._libs import index
  from pandas._libs.tslibs import BaseOffset, NaT, Period, Resolution, Tick
  from pandas._libs.tslibs.dtypes import OFFSET_TO_PERIOD_FREQSTR
  from pandas.util._decorators import cache_readonly, doc
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.common import is_integer
  from pandas.core.dtypes.dtypes import PeriodDtype
  from pandas.core.dtypes.generic import ABCSeries
  from pandas.core.dtypes.missing import is_valid_na_for_dtype
  from pandas.core.arrays.period import PeriodArray, period_array, raise_on_incompatible, validate_dtype_freq
  import pandas.core.common
  import pandas.core.indexes.base
  from pandas.core.indexes.base import maybe_extract_name
  from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin
  from pandas.core.indexes.datetimes import DatetimeIndex, Index
  from pandas.core.indexes.extension import inherit_names
label_desc: Use image node_id 8 for calling the PeriodIndex obj's underlying member method code with example usage: obj.__new__(cls, data, ordinal, freq, dtype, copy, name) and returns: cls