Skip to content

Define and document the order of index names vs column names in query eval #6676

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

Closed
cpcloud opened this issue Mar 21, 2014 · 1 comment · Fixed by #6677
Closed

Define and document the order of index names vs column names in query eval #6676

cpcloud opened this issue Mar 21, 2014 · 1 comment · Fixed by #6677
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Mar 21, 2014

Current behavior is to use the index over the columns. I think it makes more sense to prefer the columns.

Current behavior:

In [7]: n = 10

In [8]: df = DataFrame(randint(40, 50, size=(n, 2)), columns=list('ab'))

In [9]: df.index.name = 'a'

In [10]: df
Out[10]:
    a   b
a
0  43  40
1  43  46
2  41  42
3  40  45
4  41  41
5  40  45
6  47  44
7  49  41
8  40  40
9  47  40

[10 rows x 2 columns]

In [11]: df.query('a > 5')
Out[11]:
    a   b
a
6  47  44
7  49  41
8  40  40
9  47  40

[4 rows x 2 columns]

New behavior:

In [10]: df
Out[10]:
    a   b
a
0  45  47
1  44  41
2  44  48
3  47  40
4  48  48
5  47  40
6  41  47
7  44  44
8  41  41
9  40  47

[10 rows x 2 columns]

In [11]: df.query('a > 43')
Out[11]:
    a   b
a
0  45  47
1  44  41
2  44  48
3  47  40
4  48  48
5  47  40
7  44  44

[7 rows x 2 columns]
@jreback
Copy link
Contributor

jreback commented Mar 21, 2014

yep that looks right

@jreback jreback added this to the 0.14.0 milestone Mar 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants