diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index bd90325114ee1..d8b54fd5cffb3 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1282,7 +1282,7 @@ def diff(self, n: int, axis: int = 1) -> List["Block"]: new_values = _block_shape(new_values, ndim=self.ndim) return [self.make_block(values=new_values)] - def shift(self, periods, axis: int = 0, fill_value=None): + def shift(self, periods: int, axis: int = 0, fill_value=None): """ shift the block by periods, possibly upcast """ # convert integer to float if necessary. need to do a lot more than # that, handle boolean etc also diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 2f1206e800d9b..fa8799512ed05 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -545,14 +545,24 @@ def get_axe(block, qs, axes): def isna(self, func) -> "BlockManager": return self.apply("apply", func=func) - def where(self, **kwargs) -> "BlockManager": - if kwargs.pop("align", True): + def where( + self, other, cond, align: bool, errors: str, try_cast: bool, axis: int + ) -> "BlockManager": + if align: align_keys = ["other", "cond"] else: align_keys = ["cond"] - kwargs["other"] = extract_array(kwargs["other"], extract_numpy=True) + other = extract_array(other, extract_numpy=True) - return self.apply("where", align_keys=align_keys, **kwargs) + return self.apply( + "where", + align_keys=align_keys, + other=other, + cond=cond, + errors=errors, + try_cast=try_cast, + axis=axis, + ) def setitem(self, indexer, value) -> "BlockManager": return self.apply("setitem", indexer=indexer, value=value) @@ -584,11 +594,13 @@ def diff(self, n: int, axis: int) -> "BlockManager": def interpolate(self, **kwargs) -> "BlockManager": return self.apply("interpolate", **kwargs) - def shift(self, **kwargs) -> "BlockManager": - return self.apply("shift", **kwargs) + def shift(self, periods: int, axis: int, fill_value) -> "BlockManager": + return self.apply("shift", periods=periods, axis=axis, fill_value=fill_value) - def fillna(self, **kwargs) -> "BlockManager": - return self.apply("fillna", **kwargs) + def fillna(self, value, limit, inplace: bool, downcast) -> "BlockManager": + return self.apply( + "fillna", value=value, limit=limit, inplace=inplace, downcast=downcast + ) def downcast(self) -> "BlockManager": return self.apply("downcast") @@ -753,9 +765,7 @@ def combine(self, blocks: List[Block], copy: bool = True) -> "BlockManager": new_blocks = [] for b in blocks: b = b.copy(deep=copy) - b.mgr_locs = algos.take_1d( - inv_indexer, b.mgr_locs.as_array, axis=0, allow_fill=False - ) + b.mgr_locs = inv_indexer[b.mgr_locs.indexer] new_blocks.append(b) axes = list(self.axes)