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

DataFrame.from_records doesn't get dtype from empty ndarray #3682

Closed
burdanov opened this issue May 22, 2013 · 0 comments · Fixed by #3708
Closed

DataFrame.from_records doesn't get dtype from empty ndarray #3682

burdanov opened this issue May 22, 2013 · 0 comments · Fixed by #3708
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@burdanov
Copy link

a = np.array([(1, 2)], dtype=[('id', np.int64), ('value', np.int64)])
df = pd.DataFrame.from_records(a, index='id') # ok

b = np.array([], dtype=[('id', np.int64), ('value', np.int64)])
df = pd.DataFrame.from_records(b, index='id') # KeyError: 'id'

The cause is _to_arrays checks for empty data before understanding that ndarray was passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant