Skip to content

Commit 833ce28

Browse files
authored
CLN: Use to_numpy directly in cov / corr (#34031)
1 parent 5f19e31 commit 833ce28

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7980,7 +7980,7 @@ def corr(self, method="pearson", min_periods=1) -> "DataFrame":
79807980
numeric_df = self._get_numeric_data()
79817981
cols = numeric_df.columns
79827982
idx = cols.copy()
7983-
mat = numeric_df.astype(float, copy=False).to_numpy()
7983+
mat = numeric_df.to_numpy(dtype=float, na_value=np.nan, copy=False)
79847984

79857985
if method == "pearson":
79867986
correl = libalgos.nancorr(mat, minp=min_periods)
@@ -8115,7 +8115,7 @@ def cov(self, min_periods=None) -> "DataFrame":
81158115
numeric_df = self._get_numeric_data()
81168116
cols = numeric_df.columns
81178117
idx = cols.copy()
8118-
mat = numeric_df.astype(float, copy=False).to_numpy()
8118+
mat = numeric_df.to_numpy(dtype=float, na_value=np.nan, copy=False)
81198119

81208120
if notna(mat).all():
81218121
if min_periods is not None and min_periods > len(mat):

0 commit comments

Comments
 (0)