|
19 | 19 | from pandas.util._validators import validate_fillna_kwargs
|
20 | 20 |
|
21 | 21 | from pandas.core.dtypes.common import (
|
22 |
| - is_bool_dtype, is_categorical_dtype, is_datetime64_any_dtype, |
23 |
| - is_datetime64_dtype, is_datetime64tz_dtype, is_datetime_or_timedelta_dtype, |
24 |
| - is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_integer_dtype, |
25 |
| - is_list_like, is_object_dtype, is_offsetlike, is_period_dtype, |
26 |
| - is_string_dtype, is_timedelta64_dtype, is_unsigned_integer_dtype, |
27 |
| - needs_i8_conversion, pandas_dtype) |
| 22 | + is_categorical_dtype, is_datetime64_any_dtype, is_datetime64_dtype, |
| 23 | + is_datetime64tz_dtype, is_datetime_or_timedelta_dtype, is_dtype_equal, |
| 24 | + is_extension_array_dtype, is_float_dtype, is_integer_dtype, is_list_like, |
| 25 | + is_object_dtype, is_offsetlike, is_period_dtype, is_string_dtype, |
| 26 | + is_timedelta64_dtype, is_unsigned_integer_dtype, pandas_dtype) |
28 | 27 | from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
|
29 | 28 | from pandas.core.dtypes.inference import is_array_like
|
30 | 29 | from pandas.core.dtypes.missing import isna
|
|
40 | 39 | from .base import ExtensionArray, ExtensionOpsMixin
|
41 | 40 |
|
42 | 41 |
|
43 |
| -def _make_comparison_op(cls, op): |
44 |
| - # TODO: share code with indexes.base version? Main difference is that |
45 |
| - # the block for MultiIndex was removed here. |
46 |
| - def cmp_method(self, other): |
47 |
| - if isinstance(other, ABCDataFrame): |
48 |
| - return NotImplemented |
49 |
| - |
50 |
| - if needs_i8_conversion(self) and needs_i8_conversion(other): |
51 |
| - # we may need to directly compare underlying |
52 |
| - # representations |
53 |
| - return self._evaluate_compare(other, op) |
54 |
| - |
55 |
| - # numpy will show a DeprecationWarning on invalid elementwise |
56 |
| - # comparisons, this will raise in the future |
57 |
| - with warnings.catch_warnings(record=True): |
58 |
| - warnings.filterwarnings("ignore", "elementwise", FutureWarning) |
59 |
| - with np.errstate(all='ignore'): |
60 |
| - result = op(self._data, np.asarray(other)) |
61 |
| - |
62 |
| - return result |
63 |
| - |
64 |
| - name = '__{name}__'.format(name=op.__name__) |
65 |
| - # TODO: docstring? |
66 |
| - return compat.set_function_name(cmp_method, name, cls) |
67 |
| - |
68 |
| - |
69 | 42 | class AttributesMixin(object):
|
70 | 43 |
|
71 | 44 | @property
|
@@ -1358,41 +1331,6 @@ def __isub__(self, other):
|
1358 | 1331 | # --------------------------------------------------------------
|
1359 | 1332 | # Comparison Methods
|
1360 | 1333 |
|
1361 |
| - # Called by _add_comparison_methods defined in ExtensionOpsMixin |
1362 |
| - _create_comparison_method = classmethod(_make_comparison_op) |
1363 |
| - |
1364 |
| - def _evaluate_compare(self, other, op): |
1365 |
| - """ |
1366 |
| - We have been called because a comparison between |
1367 |
| - 8 aware arrays. numpy will warn about NaT comparisons |
1368 |
| - """ |
1369 |
| - # Called by comparison methods when comparing datetimelike |
1370 |
| - # with datetimelike |
1371 |
| - |
1372 |
| - if not isinstance(other, type(self)): |
1373 |
| - # coerce to a similar object |
1374 |
| - if not is_list_like(other): |
1375 |
| - # scalar |
1376 |
| - other = [other] |
1377 |
| - elif lib.is_scalar(lib.item_from_zerodim(other)): |
1378 |
| - # ndarray scalar |
1379 |
| - other = [other.item()] |
1380 |
| - other = type(self)._from_sequence(other) |
1381 |
| - |
1382 |
| - # compare |
1383 |
| - result = op(self.asi8, other.asi8) |
1384 |
| - |
1385 |
| - # technically we could support bool dtyped Index |
1386 |
| - # for now just return the indexing array directly |
1387 |
| - mask = (self._isnan) | (other._isnan) |
1388 |
| - |
1389 |
| - filler = iNaT |
1390 |
| - if is_bool_dtype(result): |
1391 |
| - filler = False |
1392 |
| - |
1393 |
| - result[mask] = filler |
1394 |
| - return result |
1395 |
| - |
1396 | 1334 | def _ensure_localized(self, arg, ambiguous='raise', nonexistent='raise',
|
1397 | 1335 | from_utc=False):
|
1398 | 1336 | """
|
@@ -1493,9 +1431,6 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
|
1493 | 1431 | return self._box_func(result)
|
1494 | 1432 |
|
1495 | 1433 |
|
1496 |
| -DatetimeLikeArrayMixin._add_comparison_ops() |
1497 |
| - |
1498 |
| - |
1499 | 1434 | # -------------------------------------------------------------------
|
1500 | 1435 | # Shared Constructor Helpers
|
1501 | 1436 |
|
|
0 commit comments