Skip to content

Commit 142a916

Browse files
Fix mypy problem
1 parent 0474001 commit 142a916

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pandas/core/indexes/category.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
import numpy as np
1212

13-
from pandas._libs import index as libindex
13+
from pandas._libs import (
14+
index as libindex,
15+
lib,
16+
)
1417
from pandas.util._decorators import (
1518
cache_readonly,
1619
doc,
@@ -453,7 +456,10 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
453456
return self.categories._is_comparable_dtype(dtype)
454457

455458
def map(
456-
self, mapper, skipna: bool = False, na_action: Literal["ignore"] | None = None
459+
self,
460+
mapper,
461+
skipna: bool = False,
462+
na_action: Literal["ignore"] | None | lib.NoDefault = lib.no_default,
457463
):
458464
"""
459465
Map values using input an input mapping or function.
@@ -530,14 +536,20 @@ def map(
530536
>>> idx.map({"a": "first", "b": "second"})
531537
Index(['first', 'second', nan], dtype='object')
532538
"""
533-
if na_action == "ignore":
539+
if na_action != lib.no_default:
534540
warnings.warn(
535541
"The ``na_action`` parameter has been deprecated and it will be "
536542
"removed in a future version of pandas. Use ``skipna`` instead.",
537543
FutureWarning,
538544
stacklevel=find_stack_level(),
539545
)
540-
skipna = True
546+
if na_action == "ignore":
547+
skipna = True
548+
elif na_action not in (None, "ignore"):
549+
raise ValueError(
550+
"na_action must either be 'ignore' or None, "
551+
f"{na_action!r} was passed"
552+
)
541553

542554
mapped = self._values.map(mapper, skipna=skipna)
543555
return Index(mapped, name=self.name)

0 commit comments

Comments
 (0)