Skip to content

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

Closed
@cpcloud

Description

@cpcloud

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]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions