diff --git a/doc/source/whatsnew/v0.17.1.txt b/doc/source/whatsnew/v0.17.1.txt index 6d4b61bb97f22..c5ae364e4a528 100755 --- a/doc/source/whatsnew/v0.17.1.txt +++ b/doc/source/whatsnew/v0.17.1.txt @@ -64,8 +64,8 @@ Bug Fixes - Bug in ``HDFStore.select`` when comparing with a numpy scalar in a where clause (:issue:`11283`) -- Bug in tz-conversions with an ambiguous time and ``.dt`` accessors (:issues:`11295`) - +- Bug in tz-conversions with an ambiguous time and ``.dt`` accessors (:issue:`11295`) +- Bug in comparisons of Series vs list-likes (:issue:`11339`) - Bug in list-like indexing with a mixed-integer Index (:issue:`11320`) diff --git a/pandas/core/ops.py b/pandas/core/ops.py index 5b3d6069f17ec..bf331ff1b781c 100644 --- a/pandas/core/ops.py +++ b/pandas/core/ops.py @@ -720,7 +720,7 @@ def wrapper(self, other, axis=None): res = op(self.values, other) else: values = self.get_values() - if is_list_like(other): + if isinstance(other, (list, np.ndarray)): other = np.asarray(other) res = na_op(values, other) diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index 9c86c3f894c67..f8d2c8bfd0dfb 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -4269,6 +4269,43 @@ def test_object_comparisons(self): expected = -(s == 'a') assert_series_equal(result, expected) + def test_comparison_tuples(self): + # GH11339 + # comparisons vs tuple + s = Series([(1,1),(1,2)]) + + result = s == (1,2) + expected = Series([False,True]) + assert_series_equal(result, expected) + + result = s != (1,2) + expected = Series([True, False]) + assert_series_equal(result, expected) + + result = s == (0,0) + expected = Series([False, False]) + assert_series_equal(result, expected) + + result = s != (0,0) + expected = Series([True, True]) + assert_series_equal(result, expected) + + s = Series([(1,1),(1,1)]) + + result = s == (1,1) + expected = Series([True, True]) + assert_series_equal(result, expected) + + result = s != (1,1) + expected = Series([False, False]) + assert_series_equal(result, expected) + + s = Series([frozenset([1]),frozenset([1,2])]) + + result = s == frozenset([1]) + expected = Series([True, False]) + assert_series_equal(result, expected) + def test_comparison_operators_with_nas(self): s = Series(bdate_range('1/1/2000', periods=10), dtype=object) s[::2] = np.nan