@@ -417,9 +417,6 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
417417 if self ._can_hold_element (value ):
418418 # equivalent: self._try_coerce_args(value) would not raise
419419 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- ]
423420 return self ._maybe_downcast (blocks , downcast )
424421
425422 # we can't process the value, but nothing to do
@@ -734,12 +731,7 @@ def _try_coerce_args(self, other):
734731
735732 return other
736733
737- def _try_coerce_result (self , result ):
738- """ reverse of try_coerce_args """
739- return result
740-
741734 def _try_coerce_and_cast_result (self , result , dtype = None ):
742- result = self ._try_coerce_result (result )
743735 result = self ._try_cast_result (result , dtype = dtype )
744736 return result
745737
@@ -1406,7 +1398,7 @@ def func(cond, values, other):
14061398
14071399 try :
14081400 fastres = expressions .where (cond , values , other )
1409- return self . _try_coerce_result ( fastres )
1401+ return fastres
14101402 except Exception as detail :
14111403 if errors == "raise" :
14121404 raise TypeError (
@@ -1692,7 +1684,6 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False)
16921684 mask = _safe_reshape (mask , new_values .shape )
16931685
16941686 new_values [mask ] = new
1695- new_values = self ._try_coerce_result (new_values )
16961687 return [self .make_block (values = new_values )]
16971688
16981689 def _try_cast_result (self , result , dtype = None ):
@@ -1870,20 +1861,6 @@ def _slice(self, slicer):
18701861
18711862 return self .values [slicer ]
18721863
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-
18871864 def formatting_values (self ):
18881865 # Deprecating the ability to override _formatting_values.
18891866 # Do the warning here, it's only user in pandas, since we
@@ -2443,20 +2420,6 @@ def _try_coerce_args(self, other):
24432420
24442421 return other
24452422
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-
24602423 def diff (self , n , axis = 0 ):
24612424 """1st discrete difference
24622425
@@ -2619,10 +2582,6 @@ def _try_coerce_args(self, other):
26192582
26202583 return other
26212584
2622- def _try_coerce_result (self , result ):
2623- """ reverse of try_coerce_args / try_operate """
2624- return result
2625-
26262585 def should_store (self , value ):
26272586 return issubclass (
26282587 value .dtype .type , np .timedelta64
@@ -3031,16 +2990,6 @@ def array_dtype(self):
30312990 """
30322991 return np .object_
30332992
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-
30442993 def to_dense (self ):
30452994 # Categorical.get_values returns a DatetimeIndex for datetime
30462995 # categories, so we can't simply use `np.asarray(self.values)` like
0 commit comments