DataFrame.from_records() KeyError when passed empty list #2633

Closed
pikeas opened this Issue Jan 4, 2013 · 3 comments

Comments

Projects
None yet
3 participants

pikeas commented Jan 4, 2013

What it says on the tin. from_records() fails with a KeyError if passed an empty list. If the list is empty, an empty DataFrame should be created, conforming to the other arguments (columns, etc).

Owner

wesm commented Jan 4, 2013

Agreed. Thanks

Contributor

changhiskhan commented Jan 5, 2013

Which version are you on? This seems to work ok on master:

In [7]: DataFrame.from_records([], index=Index([1,2]))
Out[7]: 
Empty DataFrame
Columns: []
Index: [1, 2]

pikeas commented Jan 5, 2013

pd.DataFrame.from_records([], index='foo', columns=['foo', 'bar'])

Looks like I was inaccurate about the error message thrown. The above throws an IndexError. Version 0.10.0.

wesm was assigned Jan 19, 2013

wesm closed this in dd439c9 Jan 19, 2013

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