-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: unused 'errors' keyword in where, mask #44294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1144,17 +1144,14 @@ def shift(self, periods: int, axis: int = 0, fill_value: Any = None) -> list[Blo | |
|
||
return [self.make_block(new_values)] | ||
|
||
def where(self, other, cond, errors="raise") -> list[Block]: | ||
def where(self, other, cond) -> list[Block]: | ||
""" | ||
evaluate the block; return result block(s) from the result | ||
|
||
Parameters | ||
---------- | ||
other : a ndarray/object | ||
cond : np.ndarray[bool], SparseArray[bool], or BooleanArray | ||
errors : str, {'raise', 'ignore'}, default 'raise' | ||
- ``raise`` : allow exceptions to be raised | ||
- ``ignore`` : suppress exceptions. On error return original object | ||
|
||
Returns | ||
------- | ||
|
@@ -1163,7 +1160,6 @@ def where(self, other, cond, errors="raise") -> list[Block]: | |
assert cond.ndim == self.ndim | ||
assert not isinstance(other, (ABCIndex, ABCSeries, ABCDataFrame)) | ||
|
||
assert errors in ["raise", "ignore"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are no longer raising on invalid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean remove this line but not do the rest of this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean that if we wanted to retain the validation it would now need to be higher up the stack but also probably ok that the errors parameter is no longer validated? |
||
transpose = self.ndim == 2 | ||
|
||
values = self.values | ||
|
@@ -1185,9 +1181,8 @@ def where(self, other, cond, errors="raise") -> list[Block]: | |
# or if we are a single block (ndim == 1) | ||
if not self._can_hold_element(other): | ||
# we cannot coerce, return a compat dtype | ||
# we are explicitly ignoring errors | ||
block = self.coerce_to_target_dtype(other) | ||
blocks = block.where(orig_other, cond, errors=errors) | ||
blocks = block.where(orig_other, cond) | ||
return self._maybe_downcast(blocks, "infer") | ||
|
||
# error: Argument 1 to "setitem_datetimelike_compat" has incompatible type | ||
|
@@ -1586,7 +1581,7 @@ def shift(self, periods: int, axis: int = 0, fill_value: Any = None) -> list[Blo | |
new_values = self.values.shift(periods=periods, fill_value=fill_value) | ||
return [self.make_block_same_class(new_values)] | ||
|
||
def where(self, other, cond, errors="raise") -> list[Block]: | ||
def where(self, other, cond) -> list[Block]: | ||
|
||
cond = extract_bool_array(cond) | ||
assert not isinstance(other, (ABCIndex, ABCSeries, ABCDataFrame)) | ||
|
@@ -1619,7 +1614,7 @@ def where(self, other, cond, errors="raise") -> list[Block]: | |
# For now at least only support casting e.g. | ||
# Interval[int64]->Interval[float64] | ||
raise | ||
return blk.where(other, cond, errors) | ||
return blk.where(other, cond) | ||
raise | ||
|
||
return [self.make_block_same_class(result)] | ||
|
@@ -1704,15 +1699,15 @@ def putmask(self, mask, new) -> list[Block]: | |
arr.T.putmask(mask, new) | ||
return [self] | ||
|
||
def where(self, other, cond, errors="raise") -> list[Block]: | ||
def where(self, other, cond) -> list[Block]: | ||
arr = self.values | ||
|
||
cond = extract_bool_array(cond) | ||
|
||
try: | ||
res_values = arr.T._where(cond, other).T | ||
except (ValueError, TypeError): | ||
return Block.where(self, other, cond, errors=errors) | ||
return Block.where(self, other, cond) | ||
|
||
nb = self.make_block_same_class(res_values) | ||
return [nb] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not to use the
deprecate_kwarg
decorator?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think with the decorator the warning message would be about _where instead of where/mask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that would need to use the decorator on all 4 of the public methods instead of just once here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either way works, yah