File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -1624,7 +1624,7 @@ def union_with_duplicates(
16241624 repeats = final_count .reindex (unique_vals ).values
16251625 return np .repeat (unique_vals , repeats )
16261626
1627-
1627+ import pandas as pd
16281628def map_array (
16291629 arr : ArrayLike ,
16301630 mapper ,
@@ -1698,7 +1698,7 @@ def map_array(
16981698 # we must convert to python types
16991699 #values = arr.astype(object, copy=False)
17001700
1701- if is_integer_dtype (arr ) and is_nullable_dtype (arr .dtype ):
1701+ if is_integer_dtype (arr ) and is_nullable (arr .dtype ):
17021702 def mapper_check (x ):
17031703 if x is None :
17041704 return pd .NA
Original file line number Diff line number Diff line change @@ -1446,7 +1446,7 @@ def apply_compat(self):
14461446 except (ValueError , AttributeError , TypeError ):
14471447 result = obj .apply (func , by_row = False )
14481448 return result
1449-
1449+ import pandas as pd
14501450 def apply_standard (self ) -> DataFrame | Series :
14511451 # caller is responsible for ensuring that f is Callable
14521452 func = cast (Callable , self .func )
@@ -1460,7 +1460,8 @@ def apply_standard(self) -> DataFrame | Series:
14601460
14611461 #Check if type is integer and nullable, return pd.NA for None values and
14621462 #normal func for other values
1463- if pd .api .types .is_integer_dtype (obj ) and pd .api .types .is_nullable_dtype (obj .dtype ):
1463+ if pd .api .types .is_integer_dtype (obj ) and
1464+ pd .api .types .is_nullable (obj .dtype ):
14641465 def wrapped_func (x ):
14651466 if x is None :
14661467 return pd .NA
Original file line number Diff line number Diff line change @@ -4417,7 +4417,8 @@ def map_check(val):
44174417 if callable (arg ):
44184418 arg = functools .partial (arg , ** kwargs )
44194419 new_values = self ._map_values (arg , na_action = na_action )
4420- return self ._constructor (new_values , index = self .index , copy = False ).__finalize__ (
4420+ return self ._constructor (new_values , index = self .index , copy = False )
4421+ .__finalize__ (
44214422 self , method = "map"
44224423 )
44234424
@@ -4619,16 +4620,16 @@ def apply(
46194620 Helsinki 2.484907
46204621 dtype: float64
46214622 """
4622- # check if dtype is nullable integer
4623+ # check if dtype is nullable integer
46234624 if pd .api .types .is_integer_dtype (self ) and pd .api .types .is_nullable (self .dtype ):
46244625 # def functon to handle NaN as pd.NA
4625- def apply_check (val ):
4626- if val is None :
4627- return pd .NA
4628- return val
4626+ def apply_check (val ):
4627+ if val is None :
4628+ return pd .NA
4629+ return val
46294630 self = [apply_check (x ) for x in self ]
46304631
4631- #proceed with usual apply method
4632+ #proceed with usual apply method
46324633 return SeriesApply (
46334634 self ,
46344635 func ,
You can’t perform that action at this time.
0 commit comments