@@ -412,30 +412,14 @@ def test_corrwith_kendall(self):
412412
413413 def test_corrwith_spearman_with_tied_data (self ):
414414 # GH#48826
415- df = DataFrame (
415+ df1 = DataFrame (
416416 {
417- "A" : [2 , 5 , 8 , 9 ],
418- "B" : [2 , np .nan , 8 , 9 ],
419- "C" : Series ([2 , np .nan , 8 , 9 ], dtype = "Int64" ),
420- "D" : [0 , 1 , 1 , 0 ],
421- "E" : [0 , np .nan , 1 , 0 ],
422- "F" : Series ([0 , np .nan , 1 , 0 ], dtype = "Float64" ),
423- "G" : [False , True , True , False ],
424- "H" : Series ([False , pd .NA , True , False ], dtype = "boolean" ),
425- },
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" ],
417+ "A" : [1 , np .nan , 7 , 8 ],
418+ "B" : [False , True , True , False ],
419+ "C" : [10 , 4 , 9 , 3 ],
420+ }
438421 )
439- for ser in ser_list :
440- result = df .corrwith (ser , method = "spearman" , numeric_only = False )
441- tm .assert_series_equal (result , expected )
422+ df2 = df1 [["B" , "C" ]]
423+ result = (df1 + 1 ).corrwith (df2 .B , method = "spearman" )
424+ expected = Series ([0.0 , 1.0 , 0.0 ], index = ["A" , "B" , "C" ])
425+ tm .assert_series_equal (result , expected )
0 commit comments