Skip to content

Behavior change in indexing using ix in 0.17.0 #11525

Closed
@ankurankan

Description

@ankurankan

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.

Activity

jreback

jreback commented on Nov 5, 2015

@jreback
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jreback@ankurankan

        Issue actions

          Behavior change in indexing using ix in 0.17.0 · Issue #11525 · pandas-dev/pandas