@@ -1386,97 +1386,21 @@ def test_numpy_func_call(self):
1386
1386
for func in funcs :
1387
1387
getattr (np , func )(self .frame )
1388
1388
1389
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1390
- '(GH 17386)' )
1391
- def test_where_with_int_data (self ):
1392
- # GH 17386
1393
- data = [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]]
1394
- lower_bound = 2.5
1395
-
1396
- sparse = SparseDataFrame (data )
1397
- result = sparse .where (sparse > lower_bound )
1398
-
1399
- dense = DataFrame (data )
1400
- dense_expected = dense .where (dense > lower_bound )
1401
- sparse_expected = SparseDataFrame (dense_expected )
1402
-
1403
- tm .assert_frame_equal (result , dense_expected )
1404
- tm .assert_sp_frame_equal (result , sparse_expected )
1405
-
1406
- @pytest .mark .parametrize ('other' , [
1407
- True ,
1408
- - 100 ,
1409
- 0.1 ,
1410
- 100.0 + 100.0j
1411
- ])
1412
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1413
- '(GH 17386)' )
1414
- def test_where_with_int_data_and_other (self , other ):
1415
- # GH 17386
1416
- data = [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]]
1417
- lower_bound = 2.5
1418
-
1419
- sparse = SparseDataFrame (data )
1420
- result = sparse .where (sparse > lower_bound , other )
1421
-
1422
- dense = DataFrame (data )
1423
- dense_expected = dense .where (dense > lower_bound , other )
1424
- sparse_expected = SparseDataFrame (dense_expected ,
1425
- default_fill_value = other )
1426
-
1427
- tm .assert_frame_equal (result , dense_expected )
1428
- tm .assert_sp_frame_equal (result , sparse_expected )
1429
-
1430
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1431
- '(GH 17386)' )
1432
- def test_where_with_float_data (self ):
1433
- # GH 17386
1434
- data = [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]]
1435
- lower_bound = 2.5
1436
-
1437
- sparse = SparseDataFrame (data )
1438
- result = sparse .where (sparse > lower_bound )
1439
-
1440
- dense = DataFrame (data )
1441
- dense_expected = dense .where (dense > lower_bound )
1442
- sparse_expected = SparseDataFrame (dense_expected )
1443
-
1444
- tm .assert_frame_equal (result , dense_expected )
1445
- tm .assert_sp_frame_equal (result , sparse_expected )
1446
-
1447
- @pytest .mark .parametrize ('other' , [
1448
- True ,
1449
- 0 ,
1450
- 0.1 ,
1451
- 100.0 + 100.0j
1389
+ @pytest .mark .parametrize ('data' , [
1390
+ [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]],
1391
+ [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]],
1392
+ [
1393
+ [1.0 , 1.0 + 1.0j ],
1394
+ [2.0 + 2.0j , 2.0 ],
1395
+ [3.0 , 3.0 + 3.0j ],
1396
+ [4.0 + 4.0j , 4.0 ],
1397
+ [nan , nan ]
1398
+ ]
1452
1399
])
1453
1400
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1454
1401
'(GH 17386)' )
1455
- def test_where_with_float_data_and_other (self , other ):
1402
+ def test_where_with_numeric_data (self , data ):
1456
1403
# GH 17386
1457
- data = [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]]
1458
- lower_bound = 2.5
1459
-
1460
- sparse = SparseDataFrame (data )
1461
- result = sparse .where (sparse > lower_bound , other )
1462
-
1463
- dense = DataFrame (data )
1464
- dense_expected = dense .where (dense > lower_bound , other )
1465
- sparse_expected = SparseDataFrame (dense_expected ,
1466
- default_fill_value = other )
1467
-
1468
- tm .assert_frame_equal (result , dense_expected )
1469
- tm .assert_sp_frame_equal (result , sparse_expected )
1470
-
1471
- @pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1472
- '(GH 17386)' )
1473
- def test_where_with_complex_data (self ):
1474
- # GH 17386
1475
- data = [[1.0 , 1.0 + 1.0j ],
1476
- [2.0 + 2.0j , 2.0 ],
1477
- [3.0 , 3.0 + 3.0j ],
1478
- [4.0 + 4.0j , 4.0 ],
1479
- [nan , nan ]]
1480
1404
lower_bound = 1.5
1481
1405
1482
1406
sparse = SparseDataFrame (data )
@@ -1489,21 +1413,27 @@ def test_where_with_complex_data(self):
1489
1413
tm .assert_frame_equal (result , dense_expected )
1490
1414
tm .assert_sp_frame_equal (result , sparse_expected )
1491
1415
1416
+ @pytest .mark .parametrize ('data' , [
1417
+ [[1 , 1 ], [2 , 2 ], [3 , 3 ], [4 , 4 ], [0 , 0 ]],
1418
+ [[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ], [nan , nan ]],
1419
+ [
1420
+ [1.0 , 1.0 + 1.0j ],
1421
+ [2.0 + 2.0j , 2.0 ],
1422
+ [3.0 , 3.0 + 3.0j ],
1423
+ [4.0 + 4.0j , 4.0 ],
1424
+ [nan , nan ]
1425
+ ]
1426
+ ])
1492
1427
@pytest .mark .parametrize ('other' , [
1493
1428
True ,
1494
- 0 ,
1429
+ - 100 ,
1495
1430
0.1 ,
1496
1431
100.0 + 100.0j
1497
1432
])
1498
1433
@pytest .mark .xfail (reason = 'Wrong SparseBlock initialization '
1499
1434
'(GH 17386)' )
1500
- def test_where_with_complex_data_and_other (self , other ):
1435
+ def test_where_with_numeric_data_and_other (self , data , other ):
1501
1436
# GH 17386
1502
- data = [[1.0 , 1.0 + 1.0j ],
1503
- [2.0 + 2.0j , 2.0 ],
1504
- [3.0 , 3.0 + 3.0j ],
1505
- [4.0 + 4.0j , 4.0 ],
1506
- [nan , nan ]]
1507
1437
lower_bound = 1.5
1508
1438
1509
1439
sparse = SparseDataFrame (data )
0 commit comments