Closed
Description
I am getting an error when indexing by comparing tuples:
In [13]: df = pd.DataFrame([[('A', 1), ('B', 0)], [('A', 0), ('B', 1)], [('A', 1), ('B', 0)]], columns=['A', 'B'])
In [14]: df
Out[14]:
A B
0 (A, 1) (B, 0)
1 (A, 0) (B, 1)
2 (A, 1) (B, 0)
In [15]: df[df.A == ('A', 1)]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-2663526e3e28> in <module>()
----> 1 df[df.A == ('A', 1)]
/home/ankur/anaconda3/envs/py3/lib/python3.4/site-packages/pandas/core/ops.py in wrapper(self, other, axis)
724 op_desc = _op_descriptions[op_name]
725 if op_desc['reversed']:
--> 726 equiv = 'other ' + op_desc['op'] + ' series'
727 else:
728 equiv = 'series ' + op_desc['op'] + ' other'
/home/ankur/anaconda3/envs/py3/lib/python3.4/site-packages/pandas/core/ops.py in na_op(x, y)
642 if isinstance(y, list):
643 y = lib.list_to_object_array(y)
--> 644
645 if isinstance(y, (np.ndarray, pd.Series)):
646 if (x.dtype == np.bool_ and
pandas/lib.pyx in pandas.lib.vec_compare (pandas/lib.c:14361)()
ValueError: Arrays were different lengths: 3 vs 2
But this used to work in 0.16.2, so not sure if this is expected or a bug.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jreback commentedon Nov 5, 2015
this is a dupe of: #11339
and fixed for 0.17.1
note that storing tuples inside a column is quite inefficient, and not recommended.