@@ -3336,6 +3336,16 @@ class max_speed
3336
3336
1 monkey mammal NaN
3337
3337
3 lion mammal 80.5
3338
3338
"""
3339
+ if is_copy is not None :
3340
+ warnings .warn (
3341
+ "is_copy is deprecated and will be removed in a future version. "
3342
+ "take will always return a copy in the future." ,
3343
+ FutureWarning ,
3344
+ stacklevel = 2 ,
3345
+ )
3346
+ else :
3347
+ is_copy = True
3348
+
3339
3349
nv .validate_take (tuple (), kwargs )
3340
3350
3341
3351
self ._consolidate_inplace ()
@@ -3346,17 +3356,9 @@ class max_speed
3346
3356
result = self ._constructor (new_data ).__finalize__ (self )
3347
3357
3348
3358
# Maybe set copy if we didn't actually change the index.
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
- )
3359
+ if is_copy :
3356
3360
if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3357
3361
result ._set_is_copy (self )
3358
- else :
3359
- is_copy = True
3360
3362
3361
3363
return result
3362
3364
@@ -4998,7 +5000,7 @@ def sample(
4998
5000
)
4999
5001
5000
5002
locs = rs .choice (axis_length , size = n , replace = replace , p = weights )
5001
- return self .take (locs , axis = axis )
5003
+ return self .take (locs , is_copy = False , axis = axis )
5002
5004
5003
5005
_shared_docs [
5004
5006
"pipe"
@@ -6993,7 +6995,7 @@ def asof(self, where, subset=None):
6993
6995
6994
6996
# mask the missing
6995
6997
missing = locs == - 1
6996
- data = self .take (locs )
6998
+ data = self .take (locs , is_copy = False )
6997
6999
data .index = where
6998
7000
data .loc [missing ] = np .nan
6999
7001
return data if is_list else data .iloc [- 1 ]
0 commit comments