Skip to content

NamedArray typing audit #10036

Open
Open
@ilan-gold

Description

@ilan-gold

What is your issue?

See: #9671 (comment)

At the moment, NamedArray's backing data can fulfill _arrayfunction although in practice, PandasIndexingAdapter and PandasExtensionArray don't actually fulfill this contract (although the later is much closer than the former). The following two lines are particularly problematic for non-numeric data:

@property
def imag(self) -> _arrayfunction[_ShapeType_co, Any]: ...
@property
def real(self) -> _arrayfunction[_ShapeType_co, Any]: ...

FWIW numpy arrays do always fulfill this even when it doesn't make sense (even object dtypes have a imag and real). So I'm not sure how to move forward.

Of course, another issue is the whole _DType_co being bound to numpy. __getitem__ can return pandas dtypes but __array__ won't so maybe we need a base dtype and then a numpy one as well in the generic for the class?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions