@@ -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
@@ -5007,7 +5009,7 @@ def sample(
5007
5009
)
5008
5010
5009
5011
locs = rs .choice (axis_length , size = n , replace = replace , p = weights )
5010
- return self .take (locs , axis = axis )
5012
+ return self .take (locs , is_copy = False , axis = axis )
5011
5013
5012
5014
_shared_docs [
5013
5015
"pipe"
@@ -7004,7 +7006,7 @@ def asof(self, where, subset=None):
7004
7006
7005
7007
# mask the missing
7006
7008
missing = locs == - 1
7007
- data = self .take (locs )
7009
+ data = self .take (locs , is_copy = False )
7008
7010
data .index = where
7009
7011
data .loc [missing ] = np .nan
7010
7012
return data if is_list else data .iloc [- 1 ]
0 commit comments