Skip to content

Commit a482acd

Browse files
committed
dirty fix and add integration test
1 parent 3597de0 commit a482acd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pandas/core/algorithms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def _ensure_data(values, dtype=None):
7070
# we are actually coercing to uint64
7171
# until our algos support uint8 directly (see TODO)
7272
return np.asarray(values).astype('uint64'), 'bool', 'uint64'
73-
elif is_signed_integer_dtype(values) or is_signed_integer_dtype(dtype):
73+
elif is_signed_integer_dtype(values) and is_signed_integer_dtype(dtype):
7474
return _ensure_int64(values), 'int64', 'int64'
75-
elif (is_unsigned_integer_dtype(values) or
75+
elif (is_unsigned_integer_dtype(values) and
7676
is_unsigned_integer_dtype(dtype)):
7777
return _ensure_uint64(values), 'uint64', 'uint64'
7878
elif is_float_dtype(values) or is_float_dtype(dtype):

pandas/tests/test_algos.py

+13
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,19 @@ def test_empty(self, empty):
555555
result = algos.isin(vals, empty)
556556
tm.assert_numpy_array_equal(expected, result)
557557

558+
def test_regression_issue_19356(self):
559+
# Regression test for GH19356
560+
l = [-9, -0.5]
561+
expected = np.array([True, False])
562+
563+
series_float = pd.Series([-9.0, 0.0])
564+
result_float = series_float.isin(l)
565+
tm.assert_numpy_array_equal(expected, result_float.values)
566+
567+
series_int = pd.Series([-9, 0])
568+
result_int = series_int.isin(l)
569+
tm.assert_numpy_array_equal(expected, result_int.values)
570+
558571

559572
class TestValueCounts(object):
560573

0 commit comments

Comments
 (0)