diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index e187df6d6f627..9072b90e3e7f8 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -2552,12 +2552,11 @@ class Period(_Period): hour, minute, second, freq) elif is_period_object(value): - other = value - if freq is None or freq._period_dtype_code == other.freq._period_dtype_code: - ordinal = other.ordinal - freq = other.freq + if freq is None or freq == value.freq: + ordinal = value.ordinal + freq = value.freq else: - converted = other.asfreq(freq) + converted = value.asfreq(freq) ordinal = converted.ordinal elif checknull_with_nat(value) or (isinstance(value, str) and