@@ -24,14 +24,16 @@ def test_dropEmptyRows(self, float_frame):
24
24
smaller_frame = frame .dropna (how = "all" )
25
25
# check that original was preserved
26
26
tm .assert_series_equal (frame ["foo" ], original )
27
- inplace_frame1 .dropna (how = "all" , inplace = True )
27
+ return_value = inplace_frame1 .dropna (how = "all" , inplace = True )
28
28
tm .assert_series_equal (smaller_frame ["foo" ], expected )
29
29
tm .assert_series_equal (inplace_frame1 ["foo" ], expected )
30
+ assert return_value is None
30
31
31
32
smaller_frame = frame .dropna (how = "all" , subset = ["foo" ])
32
- inplace_frame2 .dropna (how = "all" , subset = ["foo" ], inplace = True )
33
+ return_value = inplace_frame2 .dropna (how = "all" , subset = ["foo" ], inplace = True )
33
34
tm .assert_series_equal (smaller_frame ["foo" ], expected )
34
35
tm .assert_series_equal (inplace_frame2 ["foo" ], expected )
36
+ assert return_value is None
35
37
36
38
def test_dropIncompleteRows (self , float_frame ):
37
39
N = len (float_frame .index )
@@ -45,18 +47,20 @@ def test_dropIncompleteRows(self, float_frame):
45
47
46
48
smaller_frame = frame .dropna ()
47
49
tm .assert_series_equal (frame ["foo" ], original )
48
- inp_frame1 .dropna (inplace = True )
50
+ return_value = inp_frame1 .dropna (inplace = True )
49
51
50
52
exp = Series (mat [5 :], index = float_frame .index [5 :], name = "foo" )
51
53
tm .assert_series_equal (smaller_frame ["foo" ], exp )
52
54
tm .assert_series_equal (inp_frame1 ["foo" ], exp )
55
+ assert return_value is None
53
56
54
57
samesize_frame = frame .dropna (subset = ["bar" ])
55
58
tm .assert_series_equal (frame ["foo" ], original )
56
59
assert (frame ["bar" ] == 5 ).all ()
57
- inp_frame2 .dropna (subset = ["bar" ], inplace = True )
60
+ return_value = inp_frame2 .dropna (subset = ["bar" ], inplace = True )
58
61
tm .assert_index_equal (samesize_frame .index , float_frame .index )
59
62
tm .assert_index_equal (inp_frame2 .index , float_frame .index )
63
+ assert return_value is None
60
64
61
65
def test_dropna (self ):
62
66
df = DataFrame (np .random .randn (6 , 4 ))
@@ -65,31 +69,35 @@ def test_dropna(self):
65
69
dropped = df .dropna (axis = 1 )
66
70
expected = df .loc [:, [0 , 1 , 3 ]]
67
71
inp = df .copy ()
68
- inp .dropna (axis = 1 , inplace = True )
72
+ return_value = inp .dropna (axis = 1 , inplace = True )
69
73
tm .assert_frame_equal (dropped , expected )
70
74
tm .assert_frame_equal (inp , expected )
75
+ assert return_value is None
71
76
72
77
dropped = df .dropna (axis = 0 )
73
78
expected = df .loc [list (range (2 , 6 ))]
74
79
inp = df .copy ()
75
- inp .dropna (axis = 0 , inplace = True )
80
+ return_value = inp .dropna (axis = 0 , inplace = True )
76
81
tm .assert_frame_equal (dropped , expected )
77
82
tm .assert_frame_equal (inp , expected )
83
+ assert return_value is None
78
84
79
85
# threshold
80
86
dropped = df .dropna (axis = 1 , thresh = 5 )
81
87
expected = df .loc [:, [0 , 1 , 3 ]]
82
88
inp = df .copy ()
83
- inp .dropna (axis = 1 , thresh = 5 , inplace = True )
89
+ return_value = inp .dropna (axis = 1 , thresh = 5 , inplace = True )
84
90
tm .assert_frame_equal (dropped , expected )
85
91
tm .assert_frame_equal (inp , expected )
92
+ assert return_value is None
86
93
87
94
dropped = df .dropna (axis = 0 , thresh = 4 )
88
95
expected = df .loc [range (2 , 6 )]
89
96
inp = df .copy ()
90
- inp .dropna (axis = 0 , thresh = 4 , inplace = True )
97
+ return_value = inp .dropna (axis = 0 , thresh = 4 , inplace = True )
91
98
tm .assert_frame_equal (dropped , expected )
92
99
tm .assert_frame_equal (inp , expected )
100
+ assert return_value is None
93
101
94
102
dropped = df .dropna (axis = 1 , thresh = 4 )
95
103
tm .assert_frame_equal (dropped , df )
@@ -100,9 +108,10 @@ def test_dropna(self):
100
108
# subset
101
109
dropped = df .dropna (axis = 0 , subset = [0 , 1 , 3 ])
102
110
inp = df .copy ()
103
- inp .dropna (axis = 0 , subset = [0 , 1 , 3 ], inplace = True )
111
+ return_value = inp .dropna (axis = 0 , subset = [0 , 1 , 3 ], inplace = True )
104
112
tm .assert_frame_equal (dropped , df )
105
113
tm .assert_frame_equal (inp , df )
114
+ assert return_value is None
106
115
107
116
# all
108
117
dropped = df .dropna (axis = 1 , how = "all" )
@@ -126,12 +135,14 @@ def test_drop_and_dropna_caching(self):
126
135
df2 = df .copy ()
127
136
df ["A" ].dropna ()
128
137
tm .assert_series_equal (df ["A" ], original )
129
- df ["A" ].dropna (inplace = True )
138
+ return_value = df ["A" ].dropna (inplace = True )
130
139
tm .assert_series_equal (df ["A" ], expected )
140
+ assert return_value is None
131
141
df2 ["A" ].drop ([1 ])
132
142
tm .assert_series_equal (df2 ["A" ], original )
133
- df2 ["A" ].drop ([1 ], inplace = True )
143
+ return_value = df2 ["A" ].drop ([1 ], inplace = True )
134
144
tm .assert_series_equal (df2 ["A" ], original .drop ([1 ]))
145
+ assert return_value is None
135
146
136
147
def test_dropna_corner (self , float_frame ):
137
148
# bad input
@@ -251,8 +262,9 @@ def test_fillna_different_dtype(self):
251
262
)
252
263
tm .assert_frame_equal (result , expected )
253
264
254
- df .fillna ({2 : "foo" }, inplace = True )
265
+ return_value = df .fillna ({2 : "foo" }, inplace = True )
255
266
tm .assert_frame_equal (df , expected )
267
+ assert return_value is None
256
268
257
269
def test_fillna_limit_and_value (self ):
258
270
# limit and value
0 commit comments