From 0121ff376c769a44c71cdcd0da805db308d24017 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 17 Mar 2020 15:03:26 -0700 Subject: [PATCH] CLN: remove align kwarg from Block.where, Block.putmask --- pandas/core/internals/blocks.py | 37 +++++-------------------------- pandas/core/internals/managers.py | 4 ++-- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index cab2bd5146745..56b42421fe122 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -918,13 +918,7 @@ def setitem(self, indexer, value): return block def putmask( - self, - mask, - new, - align: bool = True, - inplace: bool = False, - axis: int = 0, - transpose: bool = False, + self, mask, new, inplace: bool = False, axis: int = 0, transpose: bool = False, ): """ putmask the data to the block; it is possible that we may create a @@ -936,7 +930,6 @@ def putmask( ---------- mask : the condition to respect new : a ndarray/object - align : boolean, perform alignment on other/cond, default is True inplace : perform inplace modification, default is False axis : int transpose : boolean @@ -1339,13 +1332,7 @@ def shift(self, periods, axis: int = 0, fill_value=None): return [self.make_block(new_values)] def where( - self, - other, - cond, - align: bool = True, - errors="raise", - try_cast: bool = False, - axis: int = 0, + self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0, ) -> List["Block"]: """ evaluate the block; return result block(s) from the result @@ -1354,8 +1341,6 @@ def where( ---------- other : a ndarray/object cond : the condition to respect - align : bool, default True - Perform alignment on other/cond. errors : str, {'raise', 'ignore'}, default 'raise' - ``raise`` : allow exceptions to be raised - ``ignore`` : suppress exceptions. On error return original object @@ -1421,12 +1406,7 @@ def where_func(cond, values, other): # we are explicitly ignoring errors block = self.coerce_to_target_dtype(other) blocks = block.where( - orig_other, - cond, - align=align, - errors=errors, - try_cast=try_cast, - axis=axis, + orig_other, cond, errors=errors, try_cast=try_cast, axis=axis, ) return self._maybe_downcast(blocks, "infer") @@ -1670,7 +1650,7 @@ def set(self, locs, values, check=False): self.values = values def putmask( - self, mask, new, align=True, inplace=False, axis=0, transpose=False, + self, mask, new, inplace=False, axis=0, transpose=False, ): """ putmask the data to the block; we must be a single block and not @@ -1682,7 +1662,6 @@ def putmask( ---------- mask : the condition to respect new : a ndarray/object - align : boolean, perform alignment on other/cond, default is True inplace : perform inplace modification, default is False Returns @@ -1920,13 +1899,7 @@ def shift( ] def where( - self, - other, - cond, - align=True, - errors="raise", - try_cast: bool = False, - axis: int = 0, + self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0, ) -> List["Block"]: if isinstance(other, ABCDataFrame): # ExtensionArrays are 1-D, so if we get here then diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 88cefd3ebfebf..7add379d35cac 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -406,13 +406,13 @@ def apply(self: T, f, filter=None, **kwargs) -> T: if f == "where": align_copy = True - if kwargs.get("align", True): + if kwargs.pop("align", True): align_keys = ["other", "cond"] else: align_keys = ["cond"] elif f == "putmask": align_copy = False - if kwargs.get("align", True): + if kwargs.pop("align", True): align_keys = ["new", "mask"] else: align_keys = ["mask"]