Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5d94e1b

Browse files
committedDec 2, 2011
ENH: exclude non-numeric dtypes in DataFrame.corr, motivated by #440
1 parent 01344c1 commit 5d94e1b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
 

‎RELEASE.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ pandas 0.6.1
3737
unnecessarily) (PR #425)
3838
- Use same formatting function for outputting floating point Series to console
3939
as in DataFrame (PR #420)
40+
- DataFrame.delevel will try to infer better dtype for new columns (GH #440)
41+
- Exclude non-numeric types in DataFrame.corr
4042

4143
**Bug fixes**
4244

‎pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,7 @@ def corr(self):
25712571
-------
25722572
y : DataFrame
25732573
"""
2574-
cols = self.columns
2574+
cols = self._get_numeric_columns()
25752575
mat = self.as_matrix(cols).T
25762576
baseCov = np.cov(mat)
25772577

‎pandas/tests/test_frame.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,11 @@ def test_corr(self):
20802080
assert_almost_equal(correls['A']['C'],
20812081
self.frame['A'].corr(self.frame['C']))
20822082

2083+
# exclude non-numeric types
2084+
result = self.mixed_frame.corr()
2085+
expected = self.mixed_frame.ix[:, ['A', 'B', 'C', 'D']].corr()
2086+
assert_frame_equal(result, expected)
2087+
20832088
def test_cov(self):
20842089
self.frame['A'][:5] = nan
20852090
self.frame['B'][:10] = nan

0 commit comments

Comments
 (0)
Please sign in to comment.