|
17 | 17 | _TD_DTYPE, ensure_object, is_datetime64_dtype, is_float_dtype,
|
18 | 18 | is_list_like, is_period_dtype, pandas_dtype)
|
19 | 19 | from pandas.core.dtypes.dtypes import PeriodDtype
|
20 |
| -from pandas.core.dtypes.generic import ABCIndexClass, ABCPeriodIndex, ABCSeries |
| 20 | +from pandas.core.dtypes.generic import ( |
| 21 | + ABCDataFrame, ABCIndexClass, ABCPeriodIndex, ABCSeries) |
21 | 22 | from pandas.core.dtypes.missing import isna, notna
|
22 | 23 |
|
23 | 24 | import pandas.core.algorithms as algos
|
@@ -48,26 +49,20 @@ def _period_array_cmp(cls, op):
|
48 | 49 |
|
49 | 50 | def wrapper(self, other):
|
50 | 51 | op = getattr(self.asi8, opname)
|
51 |
| - # We want to eventually defer to the Series or PeriodIndex (which will |
52 |
| - # return here with an unboxed PeriodArray). But before we do that, |
53 |
| - # we do a bit of validation on type (Period) and freq, so that our |
54 |
| - # error messages are sensible |
| 52 | + |
| 53 | + if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)): |
| 54 | + return NotImplemented |
| 55 | + |
55 | 56 | if is_list_like(other) and len(other) != len(self):
|
56 | 57 | raise ValueError("Lengths must match")
|
57 | 58 |
|
58 |
| - not_implemented = isinstance(other, (ABCSeries, ABCIndexClass)) |
59 |
| - if not_implemented: |
60 |
| - other = other._values |
61 |
| - |
62 | 59 | if isinstance(other, Period):
|
63 | 60 | self._check_compatible_with(other)
|
64 | 61 |
|
65 | 62 | result = op(other.ordinal)
|
66 | 63 | elif isinstance(other, cls):
|
67 | 64 | self._check_compatible_with(other)
|
68 | 65 |
|
69 |
| - if not_implemented: |
70 |
| - return NotImplemented |
71 | 66 | result = op(other.asi8)
|
72 | 67 |
|
73 | 68 | mask = self._isnan | other._isnan
|
|
0 commit comments