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

BUG: fix fancy indexing with empty list #6551

Merged
merged 1 commit into from
Mar 6, 2014

Conversation

immerrr
Copy link
Contributor

@immerrr immerrr commented Mar 5, 2014

This should fix #6536.

There's a side issue though with loc/ix indexers that somehow discard column names for empty indexers.

@jreback
Copy link
Contributor

jreback commented Mar 5, 2014

hmm...the names of the non-indexed axis should be ok

In [34]: df
Out[34]: 
          A  B                   C
0  0.067509  0 2013-01-01 00:00:00
1  0.872840  1 2013-01-01 00:01:00
2  0.379634  2 2013-01-01 00:02:00
3  0.552827  3 2013-01-01 00:03:00
4  0.996150  4 2013-01-01 00:04:00

[5 rows x 3 columns]

In [35]: df.loc[[]]
Out[35]: 
Empty DataFrame
Columns: [A, B, C]
Index: []

[0 rows x 3 columns]

In [36]: df.loc[:,[]]
Out[36]: 
Empty DataFrame
Columns: []
Index: [0, 1, 2, 3, 4]

[5 rows x 0 columns]

@jreback jreback added this to the 0.14.0 milestone Mar 5, 2014
@immerrr
Copy link
Contributor Author

immerrr commented Mar 5, 2014

I'm talking about names of the axes theirselves:

In [1]: pd.DataFrame(columns=pd.Series(list('abc'), name='foobar'))
Out[1]: 
Empty DataFrame
Columns: [a, b, c]
Index: []

[0 rows x 3 columns]

In [2]: pd.DataFrame(np.arange(9).reshape(3,3), columns=pd.Series(list('abc'), name='foobar'))
Out[2]: 
foobar  a  b  c
0       0  1  2
1       3  4  5
2       6  7  8

[3 rows x 3 columns]

In [3]: _2.iloc[:,[]]
Out[3]: 
Empty DataFrame
Columns: []
Index: [0, 1, 2]

[3 rows x 0 columns]

In [4]: _2.iloc[:,[]].columns.names
Out[4]: FrozenList([u'foobar'])

In [5]: _2.loc[:,[]].columns.names
Out[5]: FrozenList([None])

@jreback
Copy link
Contributor

jreback commented Mar 5, 2014

ahh..that could be (and I'll be it isn't checked in tests).....you can put it in here if you want or separate PR...(or just create a new issue for reference later)

@immerrr
Copy link
Contributor Author

immerrr commented Mar 6, 2014

Ok, as you might've seen, I think it's better to address separately and created a separate issue #6552. Is there anything else I have to do here?

@jreback
Copy link
Contributor

jreback commented Mar 6, 2014

it's good
Travis barfing for some reason
will merge soon
put a note (after this is merged) on the fixing names issues to remove those skips

@jreback jreback merged commit cbd3d5f into pandas-dev:master Mar 6, 2014
@jreback
Copy link
Contributor

jreback commented Mar 6, 2014

thanks!

@immerrr immerrr deleted the fix-fancy-indexing-empty-list branch October 15, 2014 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iloc with empty list raises IndexError
2 participants