@@ -210,17 +210,15 @@ def test_corr_nullable_integer(self, nullable_column, other_column, method):
210210 @pytest .mark .parametrize ("length" , [2 , 20 , 200 , 2000 ])
211211 def test_corr_for_constant_columns (self , length ):
212212 # GH: 37448
213- #now matches numpy behavior
213+ # now matches numpy behavior
214214 df = DataFrame (length * [[0.4 , 0.1 ]], columns = ["A" , "B" ])
215215 result = df .corr ()
216216 if length == 2 :
217217 expected = DataFrame (
218218 {"A" : [np .nan , np .nan ], "B" : [np .nan , np .nan ]}, index = ["A" , "B" ]
219219 )
220220 else :
221- expected = DataFrame (
222- {"A" : [1. , 1. ], "B" : [1. , 1. ]}, index = ["A" , "B" ]
223- )
221+ expected = DataFrame ({"A" : [1.0 , 1.0 ], "B" : [1.0 , 1.0 ]}, index = ["A" , "B" ])
224222 tm .assert_frame_equal (result , expected )
225223
226224 def test_calc_corr_small_numbers (self ):
@@ -499,3 +497,12 @@ def test_cov_with_missing_values(self):
499497 result2 = df .dropna ().cov ()
500498 tm .assert_frame_equal (result1 , expected )
501499 tm .assert_frame_equal (result2 , expected )
500+
501+ def test_close_corr (self ):
502+ values = np .array (
503+ [[30.0 , 30.100000381469727 ], [116.80000305175781 , 116.8000030517578 ]]
504+ )
505+ df = DataFrame (values .T )
506+ result = df .corr (method = "pearson" )
507+ expected = DataFrame (np .corrcoef (values [0 ], values [1 ]))
508+ tm .assert_frame_equal (result , expected )
0 commit comments