From aec8c76d994be47d91184c2332c813df3e8f99e5 Mon Sep 17 00:00:00 2001 From: DSM Date: Mon, 16 Dec 2013 14:14:19 -0500 Subject: [PATCH] Add test for DataFrame.corrwith and np.corrcoef compatibility; apparently failed once in 0.10.0. --- pandas/tests/test_frame.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index 5b501de026c57..3a29fa41046ca 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -6463,6 +6463,15 @@ def test_corrwith_series(self): assert_series_equal(result, expected) + def test_corrwith_matches_corrcoef(self): + df1 = DataFrame(np.arange(10000), columns=['a']) + df2 = DataFrame(np.arange(10000)**2, columns=['a']) + c1 = df1.corrwith(df2)['a'] + c2 = np.corrcoef(df1['a'],df2['a'])[0][1] + + assert_almost_equal(c1, c2) + self.assert_(c1 < 1) + def test_drop_names(self): df = DataFrame([[1, 2, 3],[3, 4, 5],[5, 6, 7]], index=['a', 'b', 'c'], columns=['d', 'e', 'f'])