Skip to content

Commit

Permalink
BUG: bug in comparisons vs tuples, pandas-dev#11339
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Oct 16, 2015
1 parent 89b4e5b commit 84a37c5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.17.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 37 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 84a37c5

Please sign in to comment.