Skip to content

Nullable dtypes for Series.__new__ and astype #1395

@cmp0xff

Description

@cmp0xff

At the moment, nullable Pandas dtypes in Series are recognised as their non-nullable counterparts.

Can we make the stubs revealing the distinctions?

from typing import assert_type
import pandas as pd

assert_type(pd.Series([1], dtype="Int64"), "pd.Series[pd.Int64Dtype]")  # recognised as pd.Series[int]
assert_type(pd.Series([True], dtype="boolean"), "pd.Series[pd.BooleanDtype]")  # recognised as pd.Series[bool]

assert_type(pd.Series([1]).astype("Int64"), "pd.Series[pd.Int64Dtype]")  # recognised as pd.Series[int]
assert_type(pd.Series([True]).astype("boolean"), "pd.Series[pd.BooleanDtype]")  # recognised as pd.Series[bool]

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorAstypeConstructorsSeries/DataFrame/Index/pd.array ConstructorsIndexRelated to the Index class or subclassesNeeds DiscussionRequires discussion from core team before further actionRoadmapA proposal for the roadmap.SeriesSeries data structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions