From 99aeb6b3fbeda360abf3660d3671137bbf00c5f2 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 7 Oct 2020 18:53:28 -0700 Subject: [PATCH] CLN: remove unnecessary BoolBlock.replace --- pandas/core/internals/blocks.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 09f276be7d64a..050789edbe79d 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1171,8 +1171,8 @@ def interpolate( inplace = validate_bool_kwarg(inplace, "inplace") - # Only FloatBlocks will contain NaNs. timedelta subclasses IntBlock - if (self.is_bool or self.is_integer) and not self.is_timedelta: + if not self._can_hold_na: + # If there are no NAs, then interpolate is a no-op return self if inplace else self.copy() # a fill na type method @@ -2425,15 +2425,6 @@ def _can_hold_element(self, element: Any) -> bool: return issubclass(tipo.type, np.bool_) return isinstance(element, (bool, np.bool_)) - def replace(self, to_replace, value, inplace=False, regex=False, convert=True): - inplace = validate_bool_kwarg(inplace, "inplace") - to_replace_values = np.atleast_1d(to_replace) - if not np.can_cast(to_replace_values, bool): - return self - return super().replace( - to_replace, value, inplace=inplace, regex=regex, convert=convert - ) - class ObjectBlock(Block): __slots__ = ()