Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior change in indexing using ix in 0.17.0 #11525

Closed
ankurankan opened this issue Nov 5, 2015 · 1 comment
Closed

Behavior change in indexing using ix in 0.17.0 #11525

ankurankan opened this issue Nov 5, 2015 · 1 comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions

Comments

@ankurankan
Copy link

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.

@jreback
Copy link
Contributor

jreback commented 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.

@jreback jreback closed this as completed Nov 5, 2015
@jreback jreback added Bug Dtype Conversions Unexpected or buggy dtype conversions labels Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

No branches or pull requests

2 participants