Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 21 additions & 11 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down