Skip to content

Commit

Permalink
Removing unorderable exception function
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista committed Nov 11, 2019
1 parent 2f0501f commit a62e8b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
20 changes: 0 additions & 20 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,26 +1260,6 @@ def is_datetime_or_timedelta_dtype(arr_or_dtype):
return _is_dtype_type(arr_or_dtype, classes(np.datetime64, np.timedelta64))


def _is_unorderable_exception(e: TypeError) -> bool:
"""
Check if the exception raised is an unorderable exception.
The error message differs for 3 <= PY <= 3.5 and PY >= 3.6, so
we need to condition based on Python version.
Parameters
----------
e : Exception or sub-class
The exception object to check.
Returns
-------
boolean
Whether or not the exception raised is an unorderable exception.
"""
return "'>' not supported between instances of" in str(e)


def needs_i8_conversion(arr_or_dtype):
"""
Check whether the array or dtype should be converted to int64.
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from pandas.util._validators import validate_bool_kwarg, validate_percentile

from pandas.core.dtypes.common import (
_is_unorderable_exception,
ensure_platform_int,
is_bool,
is_categorical,
Expand Down Expand Up @@ -1228,8 +1227,8 @@ def __setitem__(self, key, value):
if isinstance(key, tuple) and not isinstance(self.index, MultiIndex):
raise ValueError("Can only tuple-index with a MultiIndex")

# python 3 type errors should be raised
if _is_unorderable_exception(e):
# unorderable exception
if "'>' not supported between instances of" in str(e):
raise IndexError(key)

if com.is_bool_indexer(key):
Expand Down

0 comments on commit a62e8b0

Please sign in to comment.