Skip to content

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

Closed
@TomAugspurger

Description

@TomAugspurger
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsConstructorsSeries/DataFrame/Index/pd.array ConstructorsDtype ConversionsUnexpected or buggy dtype conversionsNeeds TestsUnit test(s) needed to prevent regressionsgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions