Skip to content

Commit a62e8b0

Browse files
Removing unorderable exception function
1 parent 2f0501f commit a62e8b0

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

pandas/core/dtypes/common.py

-20
Original file line numberDiff line numberDiff line change
@@ -1260,26 +1260,6 @@ def is_datetime_or_timedelta_dtype(arr_or_dtype):
12601260
return _is_dtype_type(arr_or_dtype, classes(np.datetime64, np.timedelta64))
12611261

12621262

1263-
def _is_unorderable_exception(e: TypeError) -> bool:
1264-
"""
1265-
Check if the exception raised is an unorderable exception.
1266-
1267-
The error message differs for 3 <= PY <= 3.5 and PY >= 3.6, so
1268-
we need to condition based on Python version.
1269-
1270-
Parameters
1271-
----------
1272-
e : Exception or sub-class
1273-
The exception object to check.
1274-
1275-
Returns
1276-
-------
1277-
boolean
1278-
Whether or not the exception raised is an unorderable exception.
1279-
"""
1280-
return "'>' not supported between instances of" in str(e)
1281-
1282-
12831263
def needs_i8_conversion(arr_or_dtype):
12841264
"""
12851265
Check whether the array or dtype should be converted to int64.

pandas/core/series.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from pandas.util._validators import validate_bool_kwarg, validate_percentile
1818

1919
from pandas.core.dtypes.common import (
20-
_is_unorderable_exception,
2120
ensure_platform_int,
2221
is_bool,
2322
is_categorical,
@@ -1228,8 +1227,8 @@ def __setitem__(self, key, value):
12281227
if isinstance(key, tuple) and not isinstance(self.index, MultiIndex):
12291228
raise ValueError("Can only tuple-index with a MultiIndex")
12301229

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

12351234
if com.is_bool_indexer(key):

0 commit comments

Comments
 (0)