@@ -3263,7 +3263,7 @@ def _clear_item_cache(self) -> None:
3263
3263
# Indexing Methods
3264
3264
3265
3265
def take (
3266
- self : FrameOrSeries , indices , axis = 0 , is_copy : bool_t = True , ** kwargs
3266
+ self : FrameOrSeries , indices , axis = 0 , is_copy : bool_t = None , ** kwargs
3267
3267
) -> FrameOrSeries :
3268
3268
"""
3269
3269
Return the elements in the given *positional* indices along an axis.
@@ -3281,6 +3281,8 @@ def take(
3281
3281
selecting rows, ``1`` means that we are selecting columns.
3282
3282
is_copy : bool, default True
3283
3283
Whether to return a copy of the original object or not.
3284
+
3285
+ .. deprecated:: 1.0.0
3284
3286
**kwargs
3285
3287
For compatibility with :meth:`numpy.take`. Has no effect on the
3286
3288
output.
@@ -3349,9 +3351,17 @@ class max_speed
3349
3351
result = self ._constructor (new_data ).__finalize__ (self )
3350
3352
3351
3353
# Maybe set copy if we didn't actually change the index.
3352
- if is_copy :
3354
+ if is_copy is not None :
3355
+ warnings .warn (
3356
+ "is_copy is deprecated and will be removed in a future version. "
3357
+ "take will always return a copy in the future." ,
3358
+ FutureWarning ,
3359
+ stacklevel = 2 ,
3360
+ )
3353
3361
if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3354
3362
result ._set_is_copy (self )
3363
+ else :
3364
+ is_copy = True
3355
3365
3356
3366
return result
3357
3367
@@ -4997,7 +5007,7 @@ def sample(
4997
5007
)
4998
5008
4999
5009
locs = rs .choice (axis_length , size = n , replace = replace , p = weights )
5000
- return self .take (locs , axis = axis , is_copy = False )
5010
+ return self .take (locs , axis = axis )
5001
5011
5002
5012
_shared_docs [
5003
5013
"pipe"
@@ -6994,7 +7004,7 @@ def asof(self, where, subset=None):
6994
7004
6995
7005
# mask the missing
6996
7006
missing = locs == - 1
6997
- data = self .take (locs , is_copy = False )
7007
+ data = self .take (locs )
6998
7008
data .index = where
6999
7009
data .loc [missing ] = np .nan
7000
7010
return data if is_list else data .iloc [- 1 ]
0 commit comments