@@ -3341,6 +3341,16 @@ class max_speed
3341
3341
1 monkey mammal NaN
3342
3342
3 lion mammal 80.5
3343
3343
"""
3344
+ if is_copy is not None :
3345
+ warnings .warn (
3346
+ "is_copy is deprecated and will be removed in a future version. "
3347
+ "take will always return a copy in the future." ,
3348
+ FutureWarning ,
3349
+ stacklevel = 2 ,
3350
+ )
3351
+ else :
3352
+ is_copy = True
3353
+
3344
3354
nv .validate_take (tuple (), kwargs )
3345
3355
3346
3356
self ._consolidate_inplace ()
@@ -3351,17 +3361,9 @@ class max_speed
3351
3361
result = self ._constructor (new_data ).__finalize__ (self )
3352
3362
3353
3363
# Maybe set copy if we didn't actually change the index.
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
- )
3364
+ if is_copy :
3361
3365
if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3362
3366
result ._set_is_copy (self )
3363
- else :
3364
- is_copy = True
3365
3367
3366
3368
return result
3367
3369
@@ -5012,7 +5014,7 @@ def sample(
5012
5014
)
5013
5015
5014
5016
locs = rs .choice (axis_length , size = n , replace = replace , p = weights )
5015
- return self .take (locs , axis = axis )
5017
+ return self .take (locs , is_copy = False , axis = axis )
5016
5018
5017
5019
_shared_docs [
5018
5020
"pipe"
@@ -7009,7 +7011,7 @@ def asof(self, where, subset=None):
7009
7011
7010
7012
# mask the missing
7011
7013
missing = locs == - 1
7012
- data = self .take (locs )
7014
+ data = self .take (locs , is_copy = False )
7013
7015
data .index = where
7014
7016
data .loc [missing ] = np .nan
7015
7017
return data if is_list else data .iloc [- 1 ]
0 commit comments