From 428cb374f0686313749a2841b76b866c3e9982b0 Mon Sep 17 00:00:00 2001 From: Kapil Sharma Date: Tue, 15 Nov 2016 19:39:08 -0600 Subject: [PATCH] Updates for Bug #14617 Index now copies the columns array instead of using the same object in covariance and correlations stats methods of dataframe --- pandas/core/frame.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 05148c1f7e80a..1ba5e55ceb2a4 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4731,6 +4731,7 @@ def corr(self, method='pearson', min_periods=1): """ numeric_df = self._get_numeric_data() cols = numeric_df.columns + idx = cols.copy() mat = numeric_df.values if method == 'pearson': @@ -4763,7 +4764,7 @@ def corr(self, method='pearson', min_periods=1): correl[i, j] = c correl[j, i] = c - return self._constructor(correl, index=cols, columns=cols) + return self._constructor(correl, index=idx, columns=cols) def cov(self, min_periods=None): """ @@ -4786,6 +4787,7 @@ def cov(self, min_periods=None): """ numeric_df = self._get_numeric_data() cols = numeric_df.columns + idx = cols.copy() mat = numeric_df.values if notnull(mat).all(): @@ -4799,7 +4801,7 @@ def cov(self, min_periods=None): baseCov = _algos.nancorr(_ensure_float64(mat), cov=True, minp=min_periods) - return self._constructor(baseCov, index=cols, columns=cols) + return self._constructor(baseCov, index=idx, columns=cols) def corrwith(self, other, axis=0, drop=False): """