-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Can't store callables using __setitem__ #13516
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 1 commit
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 |
---|---|---|
|
@@ -4455,6 +4455,9 @@ def _align_series(self, other, join='outer', axis=None, level=None, | |
raise_on_error : boolean, default True | ||
Whether to raise on invalid data types (e.g. trying to where on | ||
strings) | ||
apply_other : boolean, default True | ||
If False, other will be stored directly rather than applied to | ||
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 don't think we need another parameter 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. That's fine with me; I left it in because @sinhrks wanted it for the case where "where" is called directly rather than through setitem. 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. yeah I think we just shouldn't act on 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. How about adding internal I think applying callable to |
||
self, even if callable | ||
|
||
Returns | ||
------- | ||
|
@@ -4463,10 +4466,12 @@ def _align_series(self, other, join='outer', axis=None, level=None, | |
|
||
@Appender(_shared_docs['where'] % dict(_shared_doc_kwargs, cond="True")) | ||
def where(self, cond, other=np.nan, inplace=False, axis=None, level=None, | ||
try_cast=False, raise_on_error=True): | ||
try_cast=False, raise_on_error=True, apply_other=True): | ||
|
||
cond = com._apply_if_callable(cond, self) | ||
other = com._apply_if_callable(other, self) | ||
|
||
if apply_other: | ||
other = com._apply_if_callable(other, self) | ||
|
||
if isinstance(cond, NDFrame): | ||
cond, _ = cond.align(self, join='right', broadcast_axis=1) | ||
|
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.
actually maybe put this in API changes to make it a bit more prominent.