@@ -3353,6 +3353,16 @@ class max_speed
3353
3353
1 monkey mammal NaN
3354
3354
3 lion mammal 80.5
3355
3355
"""
3356
+ if is_copy is not None :
3357
+ warnings .warn (
3358
+ "is_copy is deprecated and will be removed in a future version. "
3359
+ "take will always return a copy in the future." ,
3360
+ FutureWarning ,
3361
+ stacklevel = 2 ,
3362
+ )
3363
+ else :
3364
+ is_copy = True
3365
+
3356
3366
nv .validate_take (tuple (), kwargs )
3357
3367
3358
3368
self ._consolidate_inplace ()
@@ -3363,17 +3373,9 @@ class max_speed
3363
3373
result = self ._constructor (new_data ).__finalize__ (self )
3364
3374
3365
3375
# Maybe set copy if we didn't actually change the index.
3366
- if is_copy is not None :
3367
- warnings .warn (
3368
- "is_copy is deprecated and will be removed in a future version. "
3369
- "take will always return a copy in the future." ,
3370
- FutureWarning ,
3371
- stacklevel = 2 ,
3372
- )
3376
+ if is_copy :
3373
3377
if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3374
3378
result ._set_is_copy (self )
3375
- else :
3376
- is_copy = True
3377
3379
3378
3380
return result
3379
3381
@@ -5024,7 +5026,7 @@ def sample(
5024
5026
)
5025
5027
5026
5028
locs = rs .choice (axis_length , size = n , replace = replace , p = weights )
5027
- return self .take (locs , axis = axis )
5029
+ return self .take (locs , is_copy = False , axis = axis )
5028
5030
5029
5031
_shared_docs [
5030
5032
"pipe"
@@ -7021,7 +7023,7 @@ def asof(self, where, subset=None):
7021
7023
7022
7024
# mask the missing
7023
7025
missing = locs == - 1
7024
- data = self .take (locs )
7026
+ data = self .take (locs , is_copy = False )
7025
7027
data .index = where
7026
7028
data .loc [missing ] = np .nan
7027
7029
return data if is_list else data .iloc [- 1 ]
0 commit comments