24
24
DtypeObj ,
25
25
IndexLabel ,
26
26
Shape ,
27
+ final ,
27
28
)
28
29
from pandas .compat import PYPY
29
30
from pandas .compat .numpy import function as nv
@@ -933,12 +934,8 @@ def _map_values(self, mapper, na_action=None):
933
934
# use the built in categorical series mapper which saves
934
935
# time by mapping the categories instead of all values
935
936
936
- # error: Incompatible types in assignment (expression has type
937
- # "Categorical", variable has type "IndexOpsMixin")
938
- self = cast ("Categorical" , self ) # type: ignore[assignment]
939
- # error: Item "ExtensionArray" of "Union[ExtensionArray, Any]" has no
940
- # attribute "map"
941
- return self ._values .map (mapper ) # type: ignore[union-attr]
937
+ cat = cast ("Categorical" , self ._values )
938
+ return cat .map (mapper )
942
939
943
940
values = self ._values
944
941
@@ -955,8 +952,7 @@ def _map_values(self, mapper, na_action=None):
955
952
raise NotImplementedError
956
953
map_f = lambda values , f : values .map (f )
957
954
else :
958
- # error: "IndexOpsMixin" has no attribute "astype"
959
- values = self .astype (object )._values # type: ignore[attr-defined]
955
+ values = self ._values .astype (object )
960
956
if na_action == "ignore" :
961
957
map_f = lambda values , f : lib .map_infer_mask (
962
958
values , f , isna (values ).view (np .uint8 )
@@ -1327,9 +1323,10 @@ def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
1327
1323
return algorithms .searchsorted (self ._values , value , side = side , sorter = sorter )
1328
1324
1329
1325
def drop_duplicates (self , keep = "first" ):
1330
- duplicated = self .duplicated (keep = keep )
1326
+ duplicated = self ._duplicated (keep = keep )
1331
1327
# error: Value of type "IndexOpsMixin" is not indexable
1332
1328
return self [~ duplicated ] # type: ignore[index]
1333
1329
1334
- def duplicated (self , keep : Union [str , bool ] = "first" ) -> np .ndarray :
1330
+ @final
1331
+ def _duplicated (self , keep : Union [str , bool ] = "first" ) -> np .ndarray :
1335
1332
return duplicated (self ._values , keep = keep )
0 commit comments