Skip to content

Commit 7fd33e3

Browse files
committed
Merge pull request #5714 from dsm054/more_corrwith_tests
Add test for DataFrame.corrwith and np.corrcoef compatibility
2 parents 033863f + aec8c76 commit 7fd33e3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/test_frame.py

+9
Original file line numberDiff line numberDiff line change
@@ -6463,6 +6463,15 @@ def test_corrwith_series(self):
64636463

64646464
assert_series_equal(result, expected)
64656465

6466+
def test_corrwith_matches_corrcoef(self):
6467+
df1 = DataFrame(np.arange(10000), columns=['a'])
6468+
df2 = DataFrame(np.arange(10000)**2, columns=['a'])
6469+
c1 = df1.corrwith(df2)['a']
6470+
c2 = np.corrcoef(df1['a'],df2['a'])[0][1]
6471+
6472+
assert_almost_equal(c1, c2)
6473+
self.assert_(c1 < 1)
6474+
64666475
def test_drop_names(self):
64676476
df = DataFrame([[1, 2, 3],[3, 4, 5],[5, 6, 7]], index=['a', 'b', 'c'],
64686477
columns=['d', 'e', 'f'])

0 commit comments

Comments
 (0)