Repository: pandas-dev/pandas

Issue:
Boolean comparison vs tuple fails in 0.17.0
Just updated to 0.17.0 (python 2.7.9 on OS X Yosemite) and I found the following:

```
>>> import pandas as pd
>>> pd.__version__
u'0.17.0'
>>> s = pd.Series([(1,1),(1,2)])
>>> s==(1,2)
0    False
1    False
dtype: bool
```

Meanwhile in 0.16.2:

```
>>> import pandas as pd
>>> pd.__version__
'0.16.2'
>>> s = pd.Series([(1,1),(1,2)])
>>> s==(1,2)
0    False
1     True
dtype: bool
```



Discussion:
Can you check that you're using the same version of numpy? I think this could actually be an issue with numpy 1.10 adjusting its casting rules...

Hi,

In both cases I have latest numpy (1.10.1). I don't know if it's related or not but I actually got to this issue because I have a Series where values are frozensets. In that case not only fails but there is also an exception. Maybe the traceback helps you to know if this is numpy- or just pandas-related

```
>>> s = pd.Series([frozenset([1]), frozenset([1,2])])
>>> s
0       (1)
1    (1, 2)
dtype: object
>>> s == frozenset([1,2])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-40-2d7a371a1a3d> in <module>()
----> 1 s == frozenset([1,2])

/Users/sancho/.virtualenvs/test/lib/python2.7/site-packages/pandas/core/ops.pyc in wrapper(self, other, axis)
    724                 other = np.asarray(other)
    725
--> 726             res = na_op(values, other)
    727             if isscalar(res):
    728                 raise TypeError('Could not compare %s type with Series'

/Users/sancho/.virtualenvs/test/lib/python2.7/site-packages/pandas/core/ops.pyc in na_op(x, y)
    644                     result = lib.vec_compare(x, y.astype(np.object_), op)
    645                 else:
--> 646                     result = lib.vec_compare(x, y, op)
    647             else:
    648                 result = lib.scalar_compare(x, y, op)

pandas/lib.pyx in pandas.lib.vec_compare (pandas/lib.c:14283)()

ValueError: Buffer has wrong number of dimensions (expected 1, got 0)
```


Resolving patch:
diff --git a/pandas/core/ops.py b/pandas/core/ops.py
--- 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)


Test patch:
diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py
--- 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