@@ -417,9 +417,6 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
417
417
if self ._can_hold_element (value ):
418
418
# equivalent: self._try_coerce_args(value) would not raise
419
419
blocks = self .putmask (mask , value , inplace = inplace )
420
- blocks = [
421
- b .make_block (values = self ._try_coerce_result (b .values )) for b in blocks
422
- ]
423
420
return self ._maybe_downcast (blocks , downcast )
424
421
425
422
# we can't process the value, but nothing to do
@@ -734,12 +731,7 @@ def _try_coerce_args(self, other):
734
731
735
732
return other
736
733
737
- def _try_coerce_result (self , result ):
738
- """ reverse of try_coerce_args """
739
- return result
740
-
741
734
def _try_coerce_and_cast_result (self , result , dtype = None ):
742
- result = self ._try_coerce_result (result )
743
735
result = self ._try_cast_result (result , dtype = dtype )
744
736
return result
745
737
@@ -1406,7 +1398,7 @@ def func(cond, values, other):
1406
1398
1407
1399
try :
1408
1400
fastres = expressions .where (cond , values , other )
1409
- return self . _try_coerce_result ( fastres )
1401
+ return fastres
1410
1402
except Exception as detail :
1411
1403
if errors == "raise" :
1412
1404
raise TypeError (
@@ -1692,7 +1684,6 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False)
1692
1684
mask = _safe_reshape (mask , new_values .shape )
1693
1685
1694
1686
new_values [mask ] = new
1695
- new_values = self ._try_coerce_result (new_values )
1696
1687
return [self .make_block (values = new_values )]
1697
1688
1698
1689
def _try_cast_result (self , result , dtype = None ):
@@ -1870,20 +1861,6 @@ def _slice(self, slicer):
1870
1861
1871
1862
return self .values [slicer ]
1872
1863
1873
- def _try_cast_result (self , result , dtype = None ):
1874
- """
1875
- if we have an operation that operates on for example floats
1876
- we want to try to cast back to our EA here if possible
1877
-
1878
- result could be a 2-D numpy array, e.g. the result of
1879
- a numeric operation; but it must be shape (1, X) because
1880
- we by-definition operate on the ExtensionBlocks one-by-one
1881
-
1882
- result could also be an EA Array itself, in which case it
1883
- is already a 1-D array
1884
- """
1885
- return result
1886
-
1887
1864
def formatting_values (self ):
1888
1865
# Deprecating the ability to override _formatting_values.
1889
1866
# Do the warning here, it's only user in pandas, since we
@@ -2443,20 +2420,6 @@ def _try_coerce_args(self, other):
2443
2420
2444
2421
return other
2445
2422
2446
- def _try_coerce_result (self , result ):
2447
- """ reverse of try_coerce_args """
2448
- if isinstance (result , np .ndarray ):
2449
- if result .ndim == 2 :
2450
- # kludge for 2D blocks with 1D EAs
2451
- result = result [0 , :]
2452
- if result .dtype == np .float64 :
2453
- # needed for post-groupby.median
2454
- result = self ._holder ._from_sequence (
2455
- result .astype (np .int64 ), freq = None , dtype = self .values .dtype
2456
- )
2457
-
2458
- return result
2459
-
2460
2423
def diff (self , n , axis = 0 ):
2461
2424
"""1st discrete difference
2462
2425
@@ -2619,10 +2582,6 @@ def _try_coerce_args(self, other):
2619
2582
2620
2583
return other
2621
2584
2622
- def _try_coerce_result (self , result ):
2623
- """ reverse of try_coerce_args / try_operate """
2624
- return result
2625
-
2626
2585
def should_store (self , value ):
2627
2586
return issubclass (
2628
2587
value .dtype .type , np .timedelta64
@@ -3031,16 +2990,6 @@ def array_dtype(self):
3031
2990
"""
3032
2991
return np .object_
3033
2992
3034
- def _try_coerce_result (self , result ):
3035
- """ reverse of try_coerce_args """
3036
-
3037
- # GH12564: CategoricalBlock is 1-dim only
3038
- # while returned results could be any dim
3039
- if (not is_categorical_dtype (result )) and isinstance (result , np .ndarray ):
3040
- result = _block_shape (result , ndim = self .ndim )
3041
-
3042
- return result
3043
-
3044
2993
def to_dense (self ):
3045
2994
# Categorical.get_values returns a DatetimeIndex for datetime
3046
2995
# categories, so we can't simply use `np.asarray(self.values)` like
0 commit comments