Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TYP: Numpy compatibility of definition of "array like" #41807

Open
Labels
ExtensionArrayExtending pandas with custom dtypes or arrays. Typingtype annotations, mypy/pyright type checking
@Dr-Irv

Description

In pandas/_typing.py, we define ArrayLike as:

ArrayLike = Union["ExtensionArray", np.ndarray]

In the numpy glossary https://numpy.org/doc/stable/glossary.html?highlight=array_like, numpy defines array_like as:

Any scalar or sequence that can be interpreted as an ndarray. In addition to ndarrays and scalars this category includes lists (possibly nested and with different element types) and tuples. Any argument accepted by numpy.array is array_like.

Are we creating confusion by using the term ArrayLike to only mean arrays, whereas numpy defines it to include scalars?

This came up in terms of reconciling the arguments of np.searchsorted() and ExtensionArray.searchsorted().

Comments from @jbrockmendel and @simonjayhawkins welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays. Typingtype annotations, mypy/pyright type checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /