|
37 | 37 | from pandas._libs.tslibs.dtypes import ( |
38 | 38 | FreqGroup, |
39 | 39 | PeriodDtypeBase, |
40 | | - freq_to_period_freqstr, |
41 | 40 | ) |
42 | 41 | from pandas._libs.tslibs.fields import isleapyear_arr |
43 | 42 | from pandas._libs.tslibs.offsets import ( |
@@ -325,7 +324,7 @@ def _from_datetime64(cls, data, freq, tz=None) -> Self: |
325 | 324 | PeriodArray[freq] |
326 | 325 | """ |
327 | 326 | if isinstance(freq, BaseOffset): |
328 | | - freq = freq_to_period_freqstr(freq.n, freq.name) |
| 327 | + freq = PeriodDtype(freq)._freqstr |
329 | 328 | data, freq = dt64arr_to_periodarr(data, freq, tz) |
330 | 329 | dtype = PeriodDtype(freq) |
331 | 330 | return cls(data, dtype=dtype) |
@@ -399,7 +398,7 @@ def freq(self) -> BaseOffset: |
399 | 398 |
|
400 | 399 | @property |
401 | 400 | def freqstr(self) -> str: |
402 | | - return freq_to_period_freqstr(self.freq.n, self.freq.name) |
| 401 | + return PeriodDtype(self.freq)._freqstr |
403 | 402 |
|
404 | 403 | def __array__(self, dtype: NpDtype | None = None) -> np.ndarray: |
405 | 404 | if dtype == "i8": |
@@ -1002,13 +1001,17 @@ def raise_on_incompatible(left, right) -> IncompatibleFrequency: |
1002 | 1001 | if isinstance(right, (np.ndarray, ABCTimedeltaArray)) or right is None: |
1003 | 1002 | other_freq = None |
1004 | 1003 | elif isinstance(right, BaseOffset): |
1005 | | - other_freq = freq_to_period_freqstr(right.n, right.name) |
| 1004 | + with warnings.catch_warnings(): |
| 1005 | + warnings.filterwarnings( |
| 1006 | + "ignore", r"PeriodDtype\[B\] is deprecated", category=FutureWarning |
| 1007 | + ) |
| 1008 | + other_freq = PeriodDtype(right)._freqstr |
1006 | 1009 | elif isinstance(right, (ABCPeriodIndex, PeriodArray, Period)): |
1007 | 1010 | other_freq = right.freqstr |
1008 | 1011 | else: |
1009 | 1012 | other_freq = delta_to_tick(Timedelta(right)).freqstr |
1010 | 1013 |
|
1011 | | - own_freq = freq_to_period_freqstr(left.freq.n, left.freq.name) |
| 1014 | + own_freq = PeriodDtype(left.freq)._freqstr |
1012 | 1015 | msg = DIFFERENT_FREQ.format( |
1013 | 1016 | cls=type(left).__name__, own_freq=own_freq, other_freq=other_freq |
1014 | 1017 | ) |
|
0 commit comments