Movatterモバイル変換


[0]ホーム

URL:


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

API (string dtype): comparisons between different string classes #60639

Closed
Labels
API - ConsistencyInternal Consistency of API/BehaviorNeeds DiscussionRequires discussion from core team before further actionNumeric OperationsArithmetic, Comparison, and Logical operationsStringsString extension data type and string data
Milestone
@rhshadrach

Description

@rhshadrach

Some comparisons between different classes of string (e.g.string[pyarrow] andstr) raise. Resolving this is straightforward except for what class should be returned. I would expect it should always be the left obj, e.g.string[pyarrow] == str should returnstring[pyarrow] whereasstr == string[pyarrow] should returnstr. Is this the concensus?

We currently run into issues with how Python handles subclasses with comparison dunders.

lhs=pd.array(["x",pd.NA,"y"],dtype="string[pyarrow]")rhs=pd.array(["x",pd.NA,"y"],dtype=pd.StringDtype("pyarrow",np.nan))print(lhs.__eq__(rhs))# <ArrowExtensionArray># [True, <NA>, True]# Length: 3, dtype: bool[pyarrow]print(lhs==rhs)# [ True False  True]

The two results above differ becauseArrowStringArrayNumpySemantics is a proper subclass ofArrowStringArray and therefore Python first callsrhs.__eq__(lhs).

We can avoid this by special casing this particular case inArrowStringArrayNumpySemantics, but I wanted to open up an issue for discussion before proceeding.

cc@WillAyd@jorisvandenbossche

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorNeeds DiscussionRequires discussion from core team before further actionNumeric OperationsArithmetic, Comparison, and Logical operationsStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp