@@ -2755,6 +2755,15 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
2755
2755
index ._cleanup ()
2756
2756
2757
2757
frame .index = index
2758
+
2759
+ if inplace :
2760
+ import warnings
2761
+ warnings .warn ("set_index with inplace=True will return None"
2762
+ " from pandas 0.11 onward" , FutureWarning )
2763
+ return self
2764
+ else :
2765
+ return frame
2766
+
2758
2767
return frame if not inplace else None
2759
2768
2760
2769
def reset_index (self , level = None , drop = False , inplace = False , col_level = 0 ,
@@ -2854,7 +2863,13 @@ def _maybe_cast(values):
2854
2863
new_obj .insert (0 , name , _maybe_cast (values ))
2855
2864
2856
2865
new_obj .index = new_index
2857
- return new_obj if not inplace else None
2866
+ if inplace :
2867
+ import warnings
2868
+ warnings .warn ("reset_index with inplace=True will return None"
2869
+ " from pandas 0.11 onward" , FutureWarning )
2870
+ return self
2871
+ else :
2872
+ return new_obj
2858
2873
2859
2874
delevel = deprecate ('delevel' , reset_index )
2860
2875
@@ -3014,6 +3029,10 @@ def drop_duplicates(self, cols=None, take_last=False, inplace=False):
3014
3029
inds , = (- duplicated ).nonzero ()
3015
3030
self ._data = self ._data .take (inds )
3016
3031
self ._clear_item_cache ()
3032
+ import warnings
3033
+ warnings .warn ("drop_duplicates with inplace=True will return None"
3034
+ " from pandas 0.11 onward" , FutureWarning )
3035
+ return self
3017
3036
else :
3018
3037
return self [- duplicated ]
3019
3038
@@ -3168,6 +3187,10 @@ def sort_index(self, axis=0, by=None, ascending=True, inplace=False):
3168
3187
self ._data = self ._data .take (indexer )
3169
3188
3170
3189
self ._clear_item_cache ()
3190
+ import warnings
3191
+ warnings .warn ("sort/sort_index with inplace=True will return None"
3192
+ " from pandas 0.11 onward" , FutureWarning )
3193
+ return self
3171
3194
else :
3172
3195
return self .take (indexer , axis = axis )
3173
3196
@@ -3210,6 +3233,10 @@ def sortlevel(self, level=0, axis=0, ascending=True, inplace=False):
3210
3233
self ._data = self ._data .take (indexer )
3211
3234
3212
3235
self ._clear_item_cache ()
3236
+ import warnings
3237
+ warnings .warn ("sortlevel with inplace=True will return None"
3238
+ " from pandas 0.11 onward" , FutureWarning )
3239
+ return self
3213
3240
else :
3214
3241
return self .take (indexer , axis = axis )
3215
3242
@@ -3337,6 +3364,10 @@ def fillna(self, value=None, method=None, axis=0, inplace=False,
3337
3364
3338
3365
if inplace :
3339
3366
self ._data = new_data
3367
+ import warnings
3368
+ warnings .warn ("fillna with inplace=True will return None"
3369
+ " from pandas 0.11 onward" , FutureWarning )
3370
+ return self
3340
3371
else :
3341
3372
return self ._constructor (new_data )
3342
3373
@@ -3384,6 +3415,11 @@ def replace(self, to_replace, value=None, method='pad', axis=0,
3384
3415
"""
3385
3416
self ._consolidate_inplace ()
3386
3417
3418
+ if inplace :
3419
+ import warnings
3420
+ warnings .warn ("replace with inplace=True will return None"
3421
+ " from pandas 0.11 onward" , FutureWarning )
3422
+
3387
3423
if value is None :
3388
3424
return self ._interpolate (to_replace , method , axis , inplace , limit )
3389
3425
else :
@@ -3416,7 +3452,7 @@ def replace(self, to_replace, value=None, method='pad', axis=0,
3416
3452
3417
3453
if inplace :
3418
3454
self ._data = new_data
3419
- return None
3455
+ return self
3420
3456
else :
3421
3457
return self ._constructor (new_data )
3422
3458
else :
@@ -3427,7 +3463,7 @@ def replace(self, to_replace, value=None, method='pad', axis=0,
3427
3463
inplace = inplace )
3428
3464
if inplace :
3429
3465
self ._data = new_data
3430
- return None
3466
+ return self
3431
3467
else :
3432
3468
return self ._constructor (new_data )
3433
3469
@@ -3534,7 +3570,13 @@ def rename(self, index=None, columns=None, copy=True, inplace=False):
3534
3570
if columns is not None :
3535
3571
result ._rename_columns_inplace (columns_f )
3536
3572
3537
- return result if not inplace else None
3573
+ if inplace :
3574
+ import warnings
3575
+ warnings .warn ("rename with inplace=True will return None"
3576
+ " from pandas 0.11 onward" , FutureWarning )
3577
+ return self
3578
+ else :
3579
+ return result
3538
3580
3539
3581
def _rename_index_inplace (self , mapper ):
3540
3582
self ._data = self ._data .rename_axis (mapper , axis = 1 )
0 commit comments