Skip to content

Commit 8237cb1

Browse files
committed
astype to float
1 parent 1691065 commit 8237cb1

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

pandas/core/frame.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7834,10 +7834,7 @@ def corr(self, method="pearson", min_periods=1) -> "DataFrame":
78347834
numeric_df = self._get_numeric_data()
78357835
cols = numeric_df.columns
78367836
idx = cols.copy()
7837-
mat = numeric_df.to_numpy()
7838-
if is_object_dtype(mat.dtype):
7839-
# We end up with an object array if pd.NA is present
7840-
mat[isna(mat)] = np.nan
7837+
mat = numeric_df.astype(float).to_numpy()
78417838

78427839
if method == "pearson":
78437840
correl = libalgos.nancorr(ensure_float64(mat), minp=min_periods)
@@ -7972,10 +7969,7 @@ def cov(self, min_periods=None) -> "DataFrame":
79727969
numeric_df = self._get_numeric_data()
79737970
cols = numeric_df.columns
79747971
idx = cols.copy()
7975-
mat = numeric_df.to_numpy()
7976-
if is_object_dtype(mat.dtype):
7977-
# We end up with an object array if pd.NA is present
7978-
mat[isna(mat)] = np.nan
7972+
mat = numeric_df.astype(float).to_numpy()
79797973

79807974
if notna(mat).all():
79817975
if min_periods is not None and min_periods > len(mat):

0 commit comments

Comments
 (0)