-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need another parameter
it's remove the callable check on other entirely
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think we just shouldn't act on other
at all.
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.
How about adding internal _where
which doesn't apply callable at all? where
can use it after applying callable.
I think applying callable to other
in where
is sometimes useful (described in #13299).
yeah that's a better soln |
|
||
@Appender(_shared_docs['where'] % dict(_shared_doc_kwargs, cond="True")) | ||
def where(self, cond, other=np.nan, inplace=False, axis=None, level=None, | ||
def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None, |
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.
Can you add a docstring to this one explaining it's purpose?
lgtm. |
lgtm. @jorisvandenbossche |
@@ -481,7 +481,7 @@ Bug Fixes | |||
- Bug in ``.tz_convert`` on a tz-aware ``DateTimeIndex`` that relied on index being sorted for correct results (:issue:`13306`) | |||
- Bug in ``pd.read_hdf()`` where attempting to load an HDF file with a single dataset, that had one or more categorical columns, failed unless the key argument was set to the name of the dataset. (:issue:`13231`) | |||
- Bug in ``.rolling()`` that allowed a negative integer window in contruction of the ``Rolling()`` object, but would later fail on aggregation (:issue:`13383`) | |||
|
|||
- Bug in ``__setitem__`` causing a callable rhs to be applied rather than stored (:issue:`13299`) |
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.
Current coverage is 84.34%@@ master #13516 diff @@
==========================================
Files 138 138
Lines 51107 51113 +6
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43103 43109 +6
Misses 8004 8004
Partials 0 0
|
Thanks a lot! |
git diff upstream/master | flake8 --diff