@@ -771,7 +771,9 @@ def test_ix_frame_align(self):
771
771
out = b .ix [:3 ]
772
772
assert_frame_equal (out , b )
773
773
774
- b .sort_index (inplace = True )
774
+ res = b .sort_index (inplace = True )
775
+ self .assertTrue (res is None )
776
+
775
777
df = df_orig .copy ()
776
778
df .ix [[0 , 1 , 2 ]] = b
777
779
out = df .ix [[0 , 1 , 2 ]].reindex (b .index )
@@ -1580,11 +1582,16 @@ def test_set_index2(self):
1580
1582
1581
1583
# inplace, single
1582
1584
df2 = df .copy ()
1583
- df2 .set_index ('C' , inplace = True )
1585
+
1586
+ res = df2 .set_index ('C' , inplace = True )
1587
+ self .assertTrue (res is None )
1588
+
1584
1589
assert_frame_equal (df2 , expected )
1585
1590
1586
1591
df3 = df .copy ()
1587
- df3 .set_index ('C' , drop = False , inplace = True )
1592
+ res = df3 .set_index ('C' , drop = False , inplace = True )
1593
+ self .assertTrue (res is None )
1594
+
1588
1595
assert_frame_equal (df3 , expected_nodrop )
1589
1596
1590
1597
# create new object, multi-column
@@ -4478,7 +4485,9 @@ def test_drop_duplicates_inplace(self):
4478
4485
4479
4486
# single column
4480
4487
df = orig .copy ()
4481
- df .drop_duplicates ('A' , inplace = True )
4488
+ res = df .drop_duplicates ('A' , inplace = True )
4489
+ self .assertTrue (res is None )
4490
+
4482
4491
expected = orig [:2 ]
4483
4492
result = df
4484
4493
assert_frame_equal (result , expected )
@@ -4491,7 +4500,8 @@ def test_drop_duplicates_inplace(self):
4491
4500
4492
4501
# multi column
4493
4502
df = orig .copy ()
4494
- df .drop_duplicates (['A' , 'B' ], inplace = True )
4503
+ res = df .drop_duplicates (['A' , 'B' ], inplace = True )
4504
+ self .assertTrue (res is None )
4495
4505
expected = orig .ix [[0 , 1 , 2 , 3 ]]
4496
4506
result = df
4497
4507
assert_frame_equal (result , expected )
@@ -4581,18 +4591,18 @@ def test_fillna_inplace(self):
4581
4591
expected = df .fillna (value = 0 )
4582
4592
self .assert_ (expected is not df )
4583
4593
4584
- df2 = df .fillna (value = 0 , inplace = True )
4585
- self .assert_ (df2 is df )
4586
- assert_frame_equal (df2 , expected )
4594
+ res = df .fillna (value = 0 , inplace = True )
4595
+ self .assert_ (res is None )
4596
+ assert_frame_equal (df , expected )
4587
4597
4588
4598
df [1 ][:4 ] = np .nan
4589
4599
df [3 ][- 4 :] = np .nan
4590
4600
expected = df .fillna (method = 'ffill' )
4591
4601
self .assert_ (expected is not df )
4592
4602
4593
- df2 = df .fillna (method = 'ffill' , inplace = True )
4594
- self .assert_ (df2 is df )
4595
- assert_frame_equal (df2 , expected )
4603
+ res = df .fillna (method = 'ffill' , inplace = True )
4604
+ self .assert_ (res is None )
4605
+ assert_frame_equal (df , expected )
4596
4606
4597
4607
def test_fillna_dict_series (self ):
4598
4608
df = DataFrame ({'a' : [nan , 1 , 2 , nan , nan ],
@@ -4641,11 +4651,13 @@ def test_replace_inplace(self):
4641
4651
self .tsframe ['A' ][- 5 :] = nan
4642
4652
4643
4653
tsframe = self .tsframe .copy ()
4644
- tsframe .replace (nan , 0 , inplace = True )
4654
+ res = tsframe .replace (nan , 0 , inplace = True )
4655
+ self .assertTrue (res is None )
4645
4656
assert_frame_equal (tsframe , self .tsframe .fillna (0 ))
4646
4657
4647
4658
tsframe = self .tsframe .copy ()
4648
- tsframe .replace (nan , method = 'pad' , inplace = True )
4659
+ res = tsframe .replace (nan , method = 'pad' , inplace = True )
4660
+ self .assertTrue (res is None )
4649
4661
assert_frame_equal (tsframe , self .tsframe .fillna (method = 'pad' ))
4650
4662
4651
4663
# mixed type
@@ -4657,7 +4669,8 @@ def test_replace_inplace(self):
4657
4669
assert_frame_equal (result , expected )
4658
4670
4659
4671
tsframe = self .tsframe .copy ()
4660
- tsframe .replace ([nan ], [0 ], inplace = True )
4672
+ res = tsframe .replace ([nan ], [0 ], inplace = True )
4673
+ self .assertTrue (res is None )
4661
4674
assert_frame_equal (tsframe , self .tsframe .fillna (0 ))
4662
4675
4663
4676
def test_replace (self ):
@@ -5336,7 +5349,8 @@ def test_where(self):
5336
5349
df = DataFrame (np .random .randn (5 , 3 ))
5337
5350
5338
5351
expected = df .mask (df < 0 )
5339
- df .where (df >= 0 , np .nan , inplace = True )
5352
+ res = df .where (df >= 0 , np .nan , inplace = True )
5353
+ self .assertTrue (res is None )
5340
5354
assert_frame_equal (df , expected )
5341
5355
5342
5356
def test_mask (self ):
@@ -5430,7 +5444,10 @@ def test_rename_inplace(self):
5430
5444
5431
5445
c_id = id (self .frame ['C' ])
5432
5446
frame = self .frame .copy ()
5433
- frame .rename (columns = {'C' : 'foo' }, inplace = True )
5447
+ res = frame .rename (columns = {'C' : 'foo' }, inplace = True )
5448
+
5449
+ self .assertTrue (res is None )
5450
+
5434
5451
self .assert_ ('C' not in frame )
5435
5452
self .assert_ ('foo' in frame )
5436
5453
self .assert_ (id (frame ['foo' ]) != c_id )
@@ -5990,7 +6007,8 @@ def test_sort_index_inplace(self):
5990
6007
unordered = frame .ix [[3 , 2 , 4 , 1 ]]
5991
6008
a_id = id (unordered ['A' ])
5992
6009
df = unordered .copy ()
5993
- df .sort_index (inplace = True )
6010
+ res = df .sort_index (inplace = True )
6011
+ self .assertTrue (res is None )
5994
6012
expected = frame
5995
6013
assert_frame_equal (df , expected )
5996
6014
self .assert_ (a_id != id (df ['A' ]))
@@ -6008,7 +6026,8 @@ def test_sort_index_inplace(self):
6008
6026
assert_frame_equal (df , expected )
6009
6027
6010
6028
df = unordered .copy ()
6011
- df .sort_index (axis = 1 , ascending = False , inplace = True )
6029
+ res = df .sort_index (axis = 1 , ascending = False , inplace = True )
6030
+ self .assertTrue (res is None )
6012
6031
expected = frame .ix [:, ::- 1 ]
6013
6032
assert_frame_equal (df , expected )
6014
6033
@@ -6046,7 +6065,8 @@ def test_sort_inplace(self):
6046
6065
columns = ['A' , 'B' , 'C' , 'D' ])
6047
6066
6048
6067
sorted_df = frame .copy ()
6049
- sorted_df .sort (columns = 'A' , inplace = True )
6068
+ res = sorted_df .sort (columns = 'A' , inplace = True )
6069
+ self .assertTrue (res is None )
6050
6070
expected = frame .sort_index (by = 'A' )
6051
6071
assert_frame_equal (sorted_df , expected )
6052
6072
@@ -6056,7 +6076,8 @@ def test_sort_inplace(self):
6056
6076
assert_frame_equal (sorted_df , expected )
6057
6077
6058
6078
sorted_df = frame .copy ()
6059
- sorted_df .sort (columns = ['A' , 'B' ], ascending = False , inplace = True )
6079
+ res = sorted_df .sort (columns = ['A' , 'B' ], ascending = False , inplace = True )
6080
+ self .assertTrue (res is None )
6060
6081
expected = frame .sort_index (by = ['A' , 'B' ], ascending = False )
6061
6082
assert_frame_equal (sorted_df , expected )
6062
6083
@@ -7126,7 +7147,8 @@ def test_reset_index(self):
7126
7147
#test resetting in place
7127
7148
df = self .frame .copy ()
7128
7149
resetted = self .frame .reset_index ()
7129
- df .reset_index (inplace = True )
7150
+ res = df .reset_index (inplace = True )
7151
+ self .assertTrue (res is None )
7130
7152
assert_frame_equal (df , resetted )
7131
7153
7132
7154
frame = self .frame .reset_index ().set_index (['index' , 'A' , 'B' ])
@@ -7251,7 +7273,8 @@ def test_consolidate(self):
7251
7273
7252
7274
self .frame ['F' ] = 8.
7253
7275
self .assert_ (len (self .frame ._data .blocks ) == 3 )
7254
- self .frame .consolidate (inplace = True )
7276
+ res = self .frame .consolidate (inplace = True )
7277
+ self .assertTrue (res is None )
7255
7278
self .assert_ (len (self .frame ._data .blocks ) == 1 )
7256
7279
7257
7280
def test_consolidate_inplace (self ):
0 commit comments