@@ -418,7 +418,7 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
418
418
419
419
# fillna, but if we cannot coerce, then try again as an ObjectBlock
420
420
try :
421
- values , _ , _ , _ = self ._try_coerce_args (self .values , value )
421
+ values , _ = self ._try_coerce_args (self .values , value )
422
422
blocks = self .putmask (mask , value , inplace = inplace )
423
423
blocks = [b .make_block (values = self ._try_coerce_result (b .values ))
424
424
for b in blocks ]
@@ -745,7 +745,7 @@ def _try_coerce_args(self, values, other):
745
745
type (other ).__name__ ,
746
746
type (self ).__name__ .lower ().replace ('Block' , '' )))
747
747
748
- return values , False , other , False
748
+ return values , other
749
749
750
750
def _try_coerce_result (self , result ):
751
751
""" reverse of try_coerce_args """
@@ -795,8 +795,8 @@ def replace(self, to_replace, value, inplace=False, filter=None,
795
795
# try to replace, if we raise an error, convert to ObjectBlock and
796
796
# retry
797
797
try :
798
- values , _ , to_replace , _ = self ._try_coerce_args (self .values ,
799
- to_replace )
798
+ values , to_replace = self ._try_coerce_args (self .values ,
799
+ to_replace )
800
800
mask = missing .mask_missing (values , to_replace )
801
801
if filter is not None :
802
802
filtered_out = ~ self .mgr_locs .isin (filter )
@@ -853,7 +853,7 @@ def setitem(self, indexer, value):
853
853
# coerce if block dtype can store value
854
854
values = self .values
855
855
try :
856
- values , _ , value , _ = self ._try_coerce_args (values , value )
856
+ values , value = self ._try_coerce_args (values , value )
857
857
# can keep its own dtype
858
858
if hasattr (value , 'dtype' ) and is_dtype_equal (values .dtype ,
859
859
value .dtype ):
@@ -985,7 +985,7 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0,
985
985
new = self .fill_value
986
986
987
987
if self ._can_hold_element (new ):
988
- _ , _ , new , _ = self ._try_coerce_args (new_values , new )
988
+ _ , new = self ._try_coerce_args (new_values , new )
989
989
990
990
if transpose :
991
991
new_values = new_values .T
@@ -1193,7 +1193,7 @@ def _interpolate_with_fill(self, method='pad', axis=0, inplace=False,
1193
1193
return [self .copy ()]
1194
1194
1195
1195
values = self .values if inplace else self .values .copy ()
1196
- values , _ , fill_value , _ = self ._try_coerce_args (values , fill_value )
1196
+ values , fill_value = self ._try_coerce_args (values , fill_value )
1197
1197
values = missing .interpolate_2d (values , method = method , axis = axis ,
1198
1198
limit = limit , fill_value = fill_value ,
1199
1199
dtype = self .dtype )
@@ -1366,8 +1366,7 @@ def func(cond, values, other):
1366
1366
if cond .ravel ().all ():
1367
1367
return values
1368
1368
1369
- values , values_mask , other , other_mask = self ._try_coerce_args (
1370
- values , other )
1369
+ values , other = self ._try_coerce_args (values , other )
1371
1370
1372
1371
try :
1373
1372
return self ._try_coerce_result (expressions .where (
@@ -1477,7 +1476,7 @@ def quantile(self, qs, interpolation='linear', axis=0, axes=None):
1477
1476
"""
1478
1477
kw = {'interpolation' : interpolation }
1479
1478
values = self .get_values ()
1480
- values , _ , _ , _ = self ._try_coerce_args (values , values )
1479
+ values , _ = self ._try_coerce_args (values , values )
1481
1480
1482
1481
def _nanpercentile1D (values , mask , q , ** kw ):
1483
1482
# mask is Union[ExtensionArray, ndarray]
@@ -1714,7 +1713,7 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0,
1714
1713
# use block's copy logic.
1715
1714
# .values may be an Index which does shallow copy by default
1716
1715
new_values = self .values if inplace else self .copy ().values
1717
- new_values , _ , new , _ = self ._try_coerce_args (new_values , new )
1716
+ new_values , new = self ._try_coerce_args (new_values , new )
1718
1717
1719
1718
if isinstance (new , np .ndarray ) and len (new ) == len (mask ):
1720
1719
new = new [mask ]
@@ -2129,35 +2128,28 @@ def _try_coerce_args(self, values, other):
2129
2128
2130
2129
Returns
2131
2130
-------
2132
- base-type values, values mask, base-type other, other mask
2131
+ base-type values, base-type other
2133
2132
"""
2134
-
2135
- values_mask = isna (values )
2136
2133
values = values .view ('i8' )
2137
- other_mask = False
2138
2134
2139
2135
if isinstance (other , bool ):
2140
2136
raise TypeError
2141
2137
elif is_null_datelike_scalar (other ):
2142
2138
other = tslibs .iNaT
2143
- other_mask = True
2144
2139
elif isinstance (other , Timedelta ):
2145
- other_mask = isna (other )
2146
2140
other = other .value
2147
2141
elif isinstance (other , timedelta ):
2148
2142
other = Timedelta (other ).value
2149
2143
elif isinstance (other , np .timedelta64 ):
2150
- other_mask = isna (other )
2151
2144
other = Timedelta (other ).value
2152
2145
elif hasattr (other , 'dtype' ) and is_timedelta64_dtype (other ):
2153
- other_mask = isna (other )
2154
2146
other = other .astype ('i8' , copy = False ).view ('i8' )
2155
2147
else :
2156
2148
# coercion issues
2157
2149
# let higher levels handle
2158
2150
raise TypeError
2159
2151
2160
- return values , values_mask , other , other_mask
2152
+ return values , other
2161
2153
2162
2154
def _try_coerce_result (self , result ):
2163
2155
""" reverse of try_coerce_args / try_operate """
@@ -2343,7 +2335,7 @@ def _try_coerce_args(self, values, other):
2343
2335
# to store DatetimeTZBlock as object
2344
2336
other = other .astype (object ).values
2345
2337
2346
- return values , False , other , False
2338
+ return values , other
2347
2339
2348
2340
def should_store (self , value ):
2349
2341
return not (issubclass (value .dtype .type ,
@@ -2682,33 +2674,29 @@ def _try_coerce_args(self, values, other):
2682
2674
2683
2675
Returns
2684
2676
-------
2685
- base-type values, values mask, base-type other, other mask
2677
+ base-type values, base-type other
2686
2678
"""
2687
2679
2688
- values_mask = isna (values )
2689
2680
values = values .view ('i8' )
2690
2681
2691
2682
if isinstance (other , bool ):
2692
2683
raise TypeError
2693
2684
elif is_null_datelike_scalar (other ):
2694
2685
other = tslibs .iNaT
2695
- other_mask = True
2696
2686
elif isinstance (other , (datetime , np .datetime64 , date )):
2697
2687
other = self ._box_func (other )
2698
2688
if getattr (other , 'tz' ) is not None :
2699
2689
raise TypeError ("cannot coerce a Timestamp with a tz on a "
2700
2690
"naive Block" )
2701
- other_mask = isna (other )
2702
2691
other = other .asm8 .view ('i8' )
2703
2692
elif hasattr (other , 'dtype' ) and is_datetime64_dtype (other ):
2704
- other_mask = isna (other )
2705
2693
other = other .astype ('i8' , copy = False ).view ('i8' )
2706
2694
else :
2707
2695
# coercion issues
2708
2696
# let higher levels handle
2709
2697
raise TypeError
2710
2698
2711
- return values , values_mask , other , other_mask
2699
+ return values , other
2712
2700
2713
2701
def _try_coerce_result (self , result ):
2714
2702
""" reverse of try_coerce_args """
@@ -2855,9 +2843,8 @@ def _try_coerce_args(self, values, other):
2855
2843
2856
2844
Returns
2857
2845
-------
2858
- base-type values, values mask, base-type other, other mask
2846
+ base-type values, base-type other
2859
2847
"""
2860
- values_mask = _block_shape (isna (values ), ndim = self .ndim )
2861
2848
# asi8 is a view, needs copy
2862
2849
values = _block_shape (values .asi8 , ndim = self .ndim )
2863
2850
@@ -2869,11 +2856,9 @@ def _try_coerce_args(self, values, other):
2869
2856
elif (is_null_datelike_scalar (other ) or
2870
2857
(lib .is_scalar (other ) and isna (other ))):
2871
2858
other = tslibs .iNaT
2872
- other_mask = True
2873
2859
elif isinstance (other , self ._holder ):
2874
2860
if other .tz != self .values .tz :
2875
2861
raise ValueError ("incompatible or non tz-aware value" )
2876
- other_mask = _block_shape (isna (other ), ndim = self .ndim )
2877
2862
other = _block_shape (other .asi8 , ndim = self .ndim )
2878
2863
elif isinstance (other , (np .datetime64 , datetime , date )):
2879
2864
other = tslibs .Timestamp (other )
@@ -2882,12 +2867,11 @@ def _try_coerce_args(self, values, other):
2882
2867
# test we can have an equal time zone
2883
2868
if tz is None or str (tz ) != str (self .values .tz ):
2884
2869
raise ValueError ("incompatible or non tz-aware value" )
2885
- other_mask = isna (other )
2886
2870
other = other .value
2887
2871
else :
2888
2872
raise TypeError
2889
2873
2890
- return values , values_mask , other , other_mask
2874
+ return values , other
2891
2875
2892
2876
def _try_coerce_result (self , result ):
2893
2877
""" reverse of try_coerce_args """
0 commit comments