Skip to content

DataFrame.from_records lose dtype info on empty recarray. #20805

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
TomAugspurger opened this issue Apr 24, 2018 · 3 comments
Closed

DataFrame.from_records lose dtype info on empty recarray. #20805

TomAugspurger opened this issue Apr 24, 2018 · 3 comments
Labels
Compat pandas objects compatability with Numpy or Python functions Constructors Series/DataFrame/Index/pd.array Constructors Dtype Conversions Unexpected or buggy dtype conversions good first issue Needs Tests Unit test(s) needed to prevent regressions

Comments

@TomAugspurger
Copy link
Contributor

In [2]: from pandas import *

In [3]: a = np.array([(1, 2)], dtype=[('id', 'u8'), ('value', 'i8')])

In [4]: DataFrame.from_records(a[:0]).dtypes
Out[4]:
id       float64
value    float64
dtype: object

I think the dtypes are incorrect. The record array dtypes should pass through so you get uint64 & int64.

Working on a PR now.

Split from #20802

@TomAugspurger TomAugspurger added the Dtype Conversions Unexpected or buggy dtype conversions label Apr 24, 2018
@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Apr 24, 2018
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Apr 24, 2018
@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Apr 24, 2018
@TomAugspurger TomAugspurger modified the milestones: 0.23.0, 0.23.1 Apr 25, 2018
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.23.1, Next Major Release Jun 6, 2018
@jbrockmendel jbrockmendel added the Constructors Series/DataFrame/Index/pd.array Constructors label Jul 23, 2019
@jbrockmendel
Copy link
Member

closed by #40121?

@jbrockmendel jbrockmendel added the Closing Candidate May be closeable, needs more eyeballs label Mar 2, 2021
@MarcoGorelli
Copy link
Member

master shows

In [14]: a = np.array([(1, 2)], dtype=[('id', 'u8'), ('value', 'i8')])
    ...: 
    ...: DataFrame.from_records(a[:0]).dtypes
Out[14]: 
id       uint64
value     int64

could do with a test?

@MarcoGorelli MarcoGorelli added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Closing Candidate May be closeable, needs more eyeballs labels Mar 21, 2021
@jbrockmendel
Copy link
Member

thats very nearly the test in #40121. closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Constructors Series/DataFrame/Index/pd.array Constructors Dtype Conversions Unexpected or buggy dtype conversions good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

No branches or pull requests

5 participants