|
1 |
| -from datetime import datetime, timedelta |
| 1 | +from datetime import datetime |
2 | 2 | import operator
|
3 | 3 | from textwrap import dedent
|
4 | 4 | from typing import Union
|
|
50 | 50 | from pandas.core.dtypes.generic import (
|
51 | 51 | ABCCategorical,
|
52 | 52 | ABCDataFrame,
|
53 |
| - ABCDateOffset, |
54 | 53 | ABCDatetimeArray,
|
55 | 54 | ABCDatetimeIndex,
|
56 | 55 | ABCIndexClass,
|
@@ -5352,51 +5351,6 @@ def _validate_for_numeric_unaryop(self, op, opstr):
|
5352 | 5351 | "{opstr} for type: {typ}".format(opstr=opstr, typ=type(self).__name__)
|
5353 | 5352 | )
|
5354 | 5353 |
|
5355 |
| - def _validate_for_numeric_binop(self, other, op): |
5356 |
| - """ |
5357 |
| - Return valid other; evaluate or raise TypeError if we are not of |
5358 |
| - the appropriate type. |
5359 |
| -
|
5360 |
| - Notes |
5361 |
| - ----- |
5362 |
| - This is an internal method called by ops. |
5363 |
| - """ |
5364 |
| - opstr = "__{opname}__".format(opname=op.__name__) |
5365 |
| - # if we are an inheritor of numeric, |
5366 |
| - # but not actually numeric (e.g. DatetimeIndex/PeriodIndex) |
5367 |
| - if not self._is_numeric_dtype: |
5368 |
| - raise TypeError( |
5369 |
| - "cannot evaluate a numeric op {opstr} " |
5370 |
| - "for type: {typ}".format(opstr=opstr, typ=type(self).__name__) |
5371 |
| - ) |
5372 |
| - |
5373 |
| - if isinstance(other, Index): |
5374 |
| - if not other._is_numeric_dtype: |
5375 |
| - raise TypeError( |
5376 |
| - "cannot evaluate a numeric op " |
5377 |
| - "{opstr} with type: {typ}".format(opstr=opstr, typ=type(other)) |
5378 |
| - ) |
5379 |
| - elif isinstance(other, np.ndarray) and not other.ndim: |
5380 |
| - other = other.item() |
5381 |
| - |
5382 |
| - if isinstance(other, (Index, ABCSeries, np.ndarray)): |
5383 |
| - if len(self) != len(other): |
5384 |
| - raise ValueError("cannot evaluate a numeric op with unequal lengths") |
5385 |
| - other = com.values_from_object(other) |
5386 |
| - if other.dtype.kind not in ["f", "i", "u"]: |
5387 |
| - raise TypeError("cannot evaluate a numeric op with a non-numeric dtype") |
5388 |
| - elif isinstance(other, (ABCDateOffset, np.timedelta64, timedelta)): |
5389 |
| - # higher up to handle |
5390 |
| - pass |
5391 |
| - elif isinstance(other, (datetime, np.datetime64)): |
5392 |
| - # higher up to handle |
5393 |
| - pass |
5394 |
| - else: |
5395 |
| - if not (is_float(other) or is_integer(other)): |
5396 |
| - raise TypeError("can only perform ops with scalar values") |
5397 |
| - |
5398 |
| - return other |
5399 |
| - |
5400 | 5354 | @classmethod
|
5401 | 5355 | def _add_numeric_methods_binary(cls):
|
5402 | 5356 | """
|
|
0 commit comments