-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
DEPR: is_copy arg of take #30615
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
DEPR: is_copy arg of take #30615
Conversation
6f4c0fc to
4368cd3
Compare
|
Not sure why my changes are making these other tests break ? |
|
looks good, needs a rebase; ping when green. |
7d503f5 to
101786a
Compare
|
Hello @ryankarlos! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-01-06 02:08:13 UTC |
c9d5f26 to
4ed4028
Compare
aea421f to
2fd97da
Compare
|
@jreback do you know why the depr warning is making the test fail specifically for Linuxpy37 ? and if i set this to |
|
The numpydev py37 build is the only one where we elevate warnings to errors which fail the build. Most likely you'll need to look at that test and what |
2fd97da to
dcb8fd2
Compare
|
thanks. @TomAugspurger @jreback found a workaround - all green now - let me know if any more changes needed. |
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.
unrelated routines, df.asof should not be showing a warning
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", FutureWarning) | ||
|
|
||
| result = df.asof(dates) |
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.
why is this showing a warning? you need to fix internally so this is not the case
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.
because the self.take(locs, is_copy=False) in def asof will now generate a warning after the deprecation change.
I could change it to default None (which sets is_copy=True) - but then that generates a SettingWithCopyError due to data.loc[missing] = np.nan in the block below
missing = locs == -1
data = self.take(locs)
data.index = where
data.loc[missing] = np.nan
I suppose I could temporarily suppress it
with pd.option_context('mode.chained_assignment', None):
data.loc[missing] = np.nan
or create a deep copy after the take operation but not sure if thats the best approach ?
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.
you simply step theu the code and out a copy where needed
| expected = df.asof(dates) | ||
| tm.assert_frame_equal(result, expected) | ||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", FutureWarning) |
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.
same
dcb8fd2 to
6c1d495
Compare
|
thanks @ryankarlos |
|
This might have caused a regression in |
| missing = locs == -1 | ||
| data = self.take(locs, is_copy=False) | ||
| d = self.take(locs) | ||
| data = d.copy() |
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.
Were there test failures if you didn't do this d.copy() step?
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.
Yes, it was breaking builds with SettingwithCopyError see #30615 (comment) and lower bit of #30615 (comment)
I think this points to a problem in the current deprecation. IMO, the goal of removing WIth the current deprecation however, the user seems to loose this ability of not needing to take a copy. So I think, when deprecating/removing the |
|
the purpose of is_copy was to force a copy so prob ok just to leave as is (maybe add a doc string) |
I don't think this is correct, as With (the name of |
This reverts commit 7796be6.
black pandasgit diff upstream/master -u -- "*.py" | flake8 --diff