def __new__(cls, data=None, ordinal=None, freq=None, dtype: (Dtype | None)=None, copy: bool=False, name: Hashable=None, **fields) -> PeriodIndex:
    valid_field_set = {'year', 'month', 'day', 'quarter', 'hour', 'minute', 'second'}
    if (not set(fields).issubset(valid_field_set)):
        argument = list((set(fields) - valid_field_set))[0]
        raise TypeError(f'__new__() got an unexpected keyword argument {argument}')
    name = maybe_extract_name(name, data, cls)
    if ((data is None) and (ordinal is None)):
        (data, freq2) = PeriodArray._generate_range(None, None, None, freq, fields)
        freq = freq2
        data = PeriodArray(data, freq=freq)
    else:
        freq = validate_dtype_freq(dtype, freq)
        if (freq and isinstance(data, cls) and (data.freq != freq)):
            data = data.asfreq(freq)
        if ((data is None) and (ordinal is not None)):
            ordinal = np.asarray(ordinal, dtype=np.int64)
            data = PeriodArray(ordinal, freq=freq)
        else:
            data = period_array(data=data, freq=freq)
    if copy:
        data = data.copy()
    return cls._simple_new(data, name=name)
def __new__(cls, data=None, ordinal=None, freq=None, dtype: (Dtype | None)=None, copy: bool=False, name: Hashable=None, **fields) -> PeriodIndex:
    valid_field_set = {'year', 'month', 'day', 'quarter', 'hour', 'minute', 'second'}
    if (not set(fields).issubset(valid_field_set)):
        argument = list((set(fields) - valid_field_set))[0]
        raise TypeError(f'__new__() got an unexpected keyword argument {argument}')
    name = maybe_extract_name(name, data, cls)
    if ((data is None) and (ordinal is None)):
        (data, freq2) = PeriodArray._generate_range(None, None, None, freq, fields)
        freq = freq2
        data = PeriodArray(data, freq=freq)
    else:
        freq = validate_dtype_freq(dtype, freq)
        if (freq and isinstance(data, cls) and (data.freq != freq)):
            data = data.asfreq(freq)
        if ((data is None) and (ordinal is not None)):
            ordinal = np.asarray(ordinal, dtype=np.int64)
            data = PeriodArray(ordinal, freq=freq)
        else:
            data = period_array(data=data, freq=freq)
    if copy:
        data = data.copy()
    return cls._simple_new(data, name=name)