@@ -410,85 +410,32 @@ def test_corrwith_kendall(self):
410
410
expected = Series (np .ones (len (result )))
411
411
tm .assert_series_equal (result , expected )
412
412
413
- @pytest .mark .parametrize (
414
- "numeric_only, ser, expected" ,
415
- [
416
- (
417
- True ,
418
- Series ([0 , 1 , 1 , 0 ]),
419
- Series ([0.0 ] * 3 + [1.0 ] * 4 , index = list ("ABCDEFH" )),
420
- ),
421
- (
422
- True ,
423
- Series ([0.0 , 1.0 , 1.0 , 0.0 ]),
424
- Series ([0.0 ] * 3 + [1.0 ] * 4 , index = list ("ABCDEFH" )),
425
- ),
426
- (
427
- True ,
428
- Series ([False , True , True , False ]),
429
- Series ([0.0 ] * 3 + [1.0 ] * 4 , index = list ("ABCDEFH" )),
430
- ),
431
- (
432
- False ,
433
- Series ([0 , 1 , 1 , 0 ]),
434
- Series ([0.0 ] * 3 + [1.0 ] * 5 , index = list ("ABCDEFGH" )),
435
- ),
436
- (
437
- False ,
438
- Series ([0.0 , 1.0 , 1.0 , 0.0 ]),
439
- Series ([0.0 ] * 3 + [1.0 ] * 5 , index = list ("ABCDEFGH" )),
440
- ),
441
- (
442
- False ,
443
- Series ([False , True , True , False ]),
444
- Series ([0.0 ] * 3 + [1.0 ] * 5 , index = list ("ABCDEFGH" )),
445
- ),
446
- (
447
- True ,
448
- Series ([0 , pd .NA , 1 , 0 ], dtype = "Int64" ),
449
- Series ([0.0 ] * 3 + [1.0 ] * 4 , index = list ("ABCDEFH" )),
450
- ),
451
- (
452
- True ,
453
- Series ([0.0 , pd .NA , 1.0 , 0.0 ], dtype = "Float64" ),
454
- Series ([0.0 ] * 3 + [1.0 ] * 4 , index = list ("ABCDEFH" )),
455
- ),
456
- (
457
- True ,
458
- Series ([False , pd .NA , True , False ], dtype = "boolean" ),
459
- Series ([0.0 ] * 3 + [1.0 ] * 4 , index = list ("ABCDEFH" )),
460
- ),
461
- (
462
- False ,
463
- Series ([0 , pd .NA , 1 , 0 ], dtype = "Int64" ),
464
- Series ([0.0 ] * 3 + [1.0 ] * 5 , index = list ("ABCDEFGH" )),
465
- ),
466
- (
467
- False ,
468
- Series ([0 , pd .NA , 1 , 0 ], dtype = "Int64" ),
469
- Series ([0.0 ] * 3 + [1.0 ] * 5 , index = list ("ABCDEFGH" )),
470
- ),
471
- (
472
- False ,
473
- Series ([False , pd .NA , True , False ], dtype = "boolean" ),
474
- Series ([0.0 ] * 3 + [1.0 ] * 5 , index = list ("ABCDEFGH" )),
475
- ),
476
- ],
477
- )
478
- def test_corrwith_spearman_with_tied_data (self , ser , numeric_only , expected ):
413
+ def test_corrwith_spearman_with_tied_data (self ):
479
414
# GH#21925
480
415
df = DataFrame (
481
416
{
482
417
"A" : [2 , 5 , 8 , 9 ],
483
418
"B" : [2 , np .nan , 8 , 9 ],
484
- "C" : [2 , np .nan , 8 , 9 ],
419
+ "C" : pd . Series ( [2 , np .nan , 8 , 9 ], dtype = "Int64" ) ,
485
420
"D" : [0 , 1 , 1 , 0 ],
486
421
"E" : [0 , np .nan , 1 , 0 ],
487
- "F" : [0 , np .nan , 1 , 0 ],
422
+ "F" : pd . Series ( [0 , np .nan , 1 , 0 ], dtype = "Float64" ) ,
488
423
"G" : [False , True , True , False ],
489
- "H" : [False , pd .NA , True , False ],
424
+ "H" : pd . Series ( [False , pd .NA , True , False ], dtype = "boolean" ) ,
490
425
},
491
- ).astype ({"C" : "Int64" , "F" : "Float64" , "H" : "boolean" })
492
- s = Series ([0 , 1 , 1 , 0 ])
493
- result = df .corrwith (s , method = "spearman" , numeric_only = numeric_only )
494
- tm .assert_series_equal (result , expected )
426
+ )
427
+ ser_list = [
428
+ Series ([0 , 1 , 1 , 0 ]),
429
+ Series ([0.0 , 1.0 , 1.0 , 0.0 ]),
430
+ Series ([False , True , True , False ]),
431
+ Series ([0 , pd .NA , 1 , 0 ], dtype = "Int64" ),
432
+ Series ([0 , pd .NA , 1 , 0 ], dtype = "Float64" ),
433
+ Series ([False , pd .NA , True , False ], dtype = "boolean" ),
434
+ ]
435
+ expected = Series (
436
+ [0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ],
437
+ index = ["A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" ],
438
+ )
439
+ for ser in ser_list :
440
+ result = df .corrwith (ser , method = "spearman" , numeric_only = False )
441
+ tm .assert_series_equal (result , expected )
0 commit comments