Skip to content

Series mask method's "other" parameter does not accept pandas.NA #692

Closed
@jasonboh

Description

@jasonboh

Describe the bug
Series.mask() method's "other" parameter does not accept pandas.NA, even though it is indeed valid to use pd.NA.

To Reproduce
import pandas as pd
series = pd.Series([1, 2, 3], dtype="Int64")
series = series.mask([True, False, False], other=pd.NA) # pyright reports the below error

Argument of type "NullableScalar" cannot be assigned to parameter "other" of type "Scalar | Series[Unknown] | DataFrame | ((...) -> Unknown)" in function "mask"
  Type "NullableScalar" cannot be assigned to type "Scalar | Series[Unknown] | DataFrame | ((...) -> Unknown)"
    Type "NAType" cannot be assigned to type "Scalar | Series[Unknown] | DataFrame | ((...) -> Unknown)"
      "NAType" is incompatible with "str"
      "NAType" is incompatible with "bytes"
      "NAType" is incompatible with "date"
      "NAType" is incompatible with "datetime"
      "NAType" is incompatible with "timedelta"
      "NAType" is incompatible with "datetime64"
...

Please complete the following information:

  • OS: Windows
  • OS Version 10
  • python version 3.10
  • version of type checker pyright with Pylance v2023.5.20
  • version of installed pandas-stubs 2.0.1.230501

Additional context
Add any other context about the problem here.

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