-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from all commits
1e1b4f1
17ca686
9bd696c
dabe051
8142050
277d925
d8db903
88dfc50
7c533a1
87b1ba5
6c1d495
0798283
e914148
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 |
---|---|---|
|
@@ -3275,7 +3275,7 @@ def _clear_item_cache(self) -> None: | |
# Indexing Methods | ||
|
||
def take( | ||
self: FrameOrSeries, indices, axis=0, is_copy: bool_t = True, **kwargs | ||
self: FrameOrSeries, indices, axis=0, is_copy: Optional[bool_t] = None, **kwargs | ||
) -> FrameOrSeries: | ||
""" | ||
Return the elements in the given *positional* indices along an axis. | ||
|
@@ -3293,6 +3293,8 @@ def take( | |
selecting rows, ``1`` means that we are selecting columns. | ||
is_copy : bool, default True | ||
Whether to return a copy of the original object or not. | ||
|
||
.. deprecated:: 1.0.0 | ||
**kwargs | ||
For compatibility with :meth:`numpy.take`. Has no effect on the | ||
output. | ||
|
@@ -3351,6 +3353,16 @@ class max_speed | |
1 monkey mammal NaN | ||
3 lion mammal 80.5 | ||
""" | ||
if is_copy is not None: | ||
warnings.warn( | ||
"is_copy is deprecated and will be removed in a future version. " | ||
"take will always return a copy in the future.", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
else: | ||
is_copy = True | ||
|
||
nv.validate_take(tuple(), kwargs) | ||
|
||
self._consolidate_inplace() | ||
|
@@ -5014,7 +5026,7 @@ def sample( | |
) | ||
|
||
locs = rs.choice(axis_length, size=n, replace=replace, p=weights) | ||
return self.take(locs, axis=axis, is_copy=False) | ||
return self.take(locs, axis=axis) | ||
|
||
_shared_docs[ | ||
"pipe" | ||
|
@@ -7011,7 +7023,8 @@ def asof(self, where, subset=None): | |
|
||
# mask the missing | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Were there test failures if you didn't do this 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. Yes, it was breaking builds with SettingwithCopyError see #30615 (comment) and lower bit of #30615 (comment) |
||
data.index = where | ||
data.loc[missing] = np.nan | ||
return data if is_list else data.iloc[-1] | ||
|
Uh oh!
There was an error while loading. Please reload this page.