@@ -289,7 +289,7 @@ def test_margin_dropna4(self):
289
289
# GH: 10772: Keep np.nan in result with dropna=False
290
290
df = DataFrame ({"a" : [1 , 2 , 2 , 2 , 2 , np .nan ], "b" : [3 , 3 , 4 , 4 , 4 , 4 ]})
291
291
actual = crosstab (df .a , df .b , margins = True , dropna = False )
292
- expected = DataFrame ([[1 , 0 , 1.0 ], [1 , 3 , 4.0 ], [0 , 1 , np . nan ], [2 , 4 , 6.0 ]])
292
+ expected = DataFrame ([[1 , 0 , 1 ], [1 , 3 , 4 ], [0 , 1 , 1 ], [2 , 4 , 6 ]])
293
293
expected .index = Index ([1.0 , 2.0 , np .nan , "All" ], name = "a" )
294
294
expected .columns = Index ([3 , 4 , "All" ], name = "b" )
295
295
tm .assert_frame_equal (actual , expected )
@@ -301,11 +301,11 @@ def test_margin_dropna5(self):
301
301
)
302
302
actual = crosstab (df .a , df .b , margins = True , dropna = False )
303
303
expected = DataFrame (
304
- [[1 , 0 , 0 , 1.0 ], [0 , 1 , 0 , 1.0 ], [0 , 3 , 1 , np . nan ], [1 , 4 , 0 , 6.0 ]]
304
+ [[1 , 0 , 0 , 1.0 ], [0 , 1 , 0 , 1.0 ], [0 , 3 , 1 , 4.0 ], [1 , 4 , 1 , 6.0 ]]
305
305
)
306
306
expected .index = Index ([1.0 , 2.0 , np .nan , "All" ], name = "a" )
307
307
expected .columns = Index ([3.0 , 4.0 , np .nan , "All" ], name = "b" )
308
- tm .assert_frame_equal (actual , expected )
308
+ tm .assert_frame_equal (actual , expected , check_dtype = False )
309
309
310
310
def test_margin_dropna6 (self ):
311
311
# GH: 10772: Keep np.nan in result with dropna=False
@@ -326,7 +326,7 @@ def test_margin_dropna6(self):
326
326
names = ["b" , "c" ],
327
327
)
328
328
expected = DataFrame (
329
- [[1 , 0 , 1 , 0 , 0 , 0 , 2 ], [2 , 0 , 1 , 1 , 0 , 1 , 5 ], [3 , 0 , 2 , 1 , 0 , 0 , 7 ]],
329
+ [[1 , 0 , 1 , 0 , 0 , 0 , 2 ], [2 , 0 , 1 , 1 , 0 , 1 , 5 ], [3 , 0 , 2 , 1 , 0 , 1 , 7 ]],
330
330
columns = m ,
331
331
)
332
332
expected .index = Index (["bar" , "foo" , "All" ], name = "a" )
@@ -344,13 +344,13 @@ def test_margin_dropna6(self):
344
344
)
345
345
expected = DataFrame (
346
346
[
347
- [1 , 0 , 1.0 ],
348
- [1 , 0 , 1.0 ],
347
+ [1 , 0 , 1 ],
348
+ [1 , 0 , 1 ],
349
349
[0 , 0 , np .nan ],
350
- [2 , 0 , 2.0 ],
351
- [1 , 1 , 2.0 ],
352
- [0 , 1 , np . nan ],
353
- [5 , 2 , 7.0 ],
350
+ [2 , 0 , 2 ],
351
+ [1 , 1 , 2 ],
352
+ [0 , 1 , 1 ],
353
+ [5 , 2 , 7 ],
354
354
],
355
355
index = m ,
356
356
)
0 commit comments