File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -1286,11 +1286,20 @@ def test_from_scipy_fillna(spmatrix):
12861286 sdf = pd .SparseDataFrame (spm ).fillna (- 1.0 )
12871287
12881288 # Returning frame should fill all nan values with -1.0
1289- expected = pd .SparseDataFrame ([[1 , - 1 , - 1 ],
1290- [- 1 , 1 , - 1 ],
1291- [- 1 , - 1 , 1. ]])
1289+ expected = pd .SparseDataFrame ({
1290+ 0 : pd .SparseSeries ([1. , - 1 , - 1 ]),
1291+ 1 : pd .SparseSeries ([np .nan , 1 , np .nan ]),
1292+ 2 : pd .SparseSeries ([np .nan , np .nan , 1 ]),
1293+ }, default_fill_value = - 1 )
1294+
1295+ # fill_value is expected to be what .fillna() above was called with
1296+ # We don't use -1 as initial fill_value in expected SparseSeries
1297+ # construction because this way we obtain "compressed" SparseArrays,
1298+ # avoiding having to construct them ourselves
1299+ for col in expected :
1300+ expected [col ].fill_value = - 1
12921301
1293- tm .assert_numpy_array_equal (sdf . values , expected . values )
1302+ tm .assert_sp_frame_equal (sdf , expected )
12941303
12951304
12961305class TestSparseDataFrameArithmetic (object ):
You can’t perform that action at this time.
0 commit comments