Skip to content

BUG: mix of int and pd.NA defaults to object dtype #33662

Open
@eddy-geek

Description

@eddy-geek
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.


Code Sample, a copy-pastable example

On pandas 1.0.3:

df = pd.DataFrame([7,8,9,pd.NA])
print(df.dtypes) 
# 0    object
# dtype: object

Problem description

Creating a DataFrame with mixed int and pd.NA defaults to object instead of Int64

According to @simonjayhawkins in #32931

since pd.NA is experimental, changing the constructor to default to the best possible dtypes using dtypes supporting pd.NA seems reasonable.

Expected Output

pd.DataFrame([7,8,9,pd.NA]).dtypes
# 0    Int64
# dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConstructorsSeries/DataFrame/Index/pd.array ConstructorsDtype ConversionsUnexpected or buggy dtype conversionsEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.NA - MaskedArraysRelated to pd.NA and nullable extension arraysNeeds DiscussionRequires discussion from core team before further actionPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions