-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Open
Labels
ConstructorsSeries/DataFrame/Index/pd.array ConstructorsSeries/DataFrame/Index/pd.array ConstructorsDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.NA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arraysNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprintIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint
Description
-
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
Labels
ConstructorsSeries/DataFrame/Index/pd.array ConstructorsSeries/DataFrame/Index/pd.array ConstructorsDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.NA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arraysNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprintIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint