@@ -3259,7 +3259,7 @@ def _clear_item_cache(self) -> None:
3259
3259
# ----------------------------------------------------------------------
3260
3260
# Indexing Methods
3261
3261
3262
- def take (self , indices , axis = 0 , is_copy : bool_t = True , ** kwargs ):
3262
+ def take (self , indices , axis = 0 , is_copy : bool_t = None , ** kwargs ):
3263
3263
"""
3264
3264
Return the elements in the given *positional* indices along an axis.
3265
3265
@@ -3276,6 +3276,8 @@ def take(self, indices, axis=0, is_copy: bool_t = True, **kwargs):
3276
3276
selecting rows, ``1`` means that we are selecting columns.
3277
3277
is_copy : bool, default True
3278
3278
Whether to return a copy of the original object or not.
3279
+
3280
+ .. deprecated:: 1.0.0
3279
3281
**kwargs
3280
3282
For compatibility with :meth:`numpy.take`. Has no effect on the
3281
3283
output.
@@ -3344,9 +3346,17 @@ class max_speed
3344
3346
result = self ._constructor (new_data ).__finalize__ (self )
3345
3347
3346
3348
# Maybe set copy if we didn't actually change the index.
3347
- if is_copy :
3349
+ if is_copy is not None :
3350
+ warnings .warn (
3351
+ "is_copy is deprecated and will be removed in a future version. "
3352
+ "take will always return a copy in the future." ,
3353
+ FutureWarning ,
3354
+ stacklevel = 2 ,
3355
+ )
3348
3356
if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3349
3357
result ._set_is_copy (self )
3358
+ else :
3359
+ is_copy = True
3350
3360
3351
3361
return result
3352
3362
@@ -4988,7 +4998,7 @@ def sample(
4988
4998
)
4989
4999
4990
5000
locs = rs .choice (axis_length , size = n , replace = replace , p = weights )
4991
- return self .take (locs , axis = axis , is_copy = False )
5001
+ return self .take (locs , axis = axis )
4992
5002
4993
5003
_shared_docs [
4994
5004
"pipe"
@@ -6983,7 +6993,7 @@ def asof(self, where, subset=None):
6983
6993
6984
6994
# mask the missing
6985
6995
missing = locs == - 1
6986
- data = self .take (locs , is_copy = False )
6996
+ data = self .take (locs )
6987
6997
data .index = where
6988
6998
data .loc [missing ] = np .nan
6989
6999
return data if is_list else data .iloc [- 1 ]
0 commit comments