Skip to content

Commit 60000ca

Browse files
committed
removing try and execpt for better look
1 parent 80752ad commit 60000ca

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pandas/core/algorithms.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,13 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
428428
# TODO(extension)
429429
# handle categoricals
430430
return comps.isin(values) # type: ignore
431-
try:
431+
432+
if hasattr(comps, "dtype") and hasattr(comps.dtype, "name"):
432433
if comps.dtype.name == "int64":
433434
comps, dtype = _ensure_data(comps, dtype=object)
434435
else:
435436
comps, dtype = _ensure_data(comps)
436-
except:
437+
else:
437438
comps, dtype = _ensure_data(comps)
438439

439440
values, _ = _ensure_data(values, dtype=dtype)

pandas/tests/frame/methods/test_isin.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def test_isin_empty_datetimelike(self):
191191
tm.assert_frame_equal(result, expected)
192192

193193
def test_isin_int_df_string_search(self):
194-
# Comparing df with int`s (1,2) with a string at isin() ("1") -> should not match values because int 1 is not equal str 1
194+
"""Comparing df with int`s (1,2) with a string at isin() ("1")
195+
-> should not match values because int 1 is not equal str 1"""
195196
df = DataFrame({"values": [1, 2]})
196197
result = df.isin(["1"])
197198
expected_false = pd.DataFrame({"values": [False, False]})

0 commit comments

Comments
 (0)