Skip to content

Commit bda0025

Browse files
committed
ENH: Add TypeError for unsupported datetime64 and timedelta64 dtypes in DataFrame.cov
1 parent e557039 commit bda0025

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/core/frame.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11239,6 +11239,12 @@ def cov(
1123911239
c -0.150812 0.191417 0.895202
1124011240
"""
1124111241
data = self._get_numeric_data() if numeric_only else self
11242+
if data.select_dtypes(include=[np.datetime64, np.timedelta64]).shape[1] > 0:
11243+
msg = (
11244+
"DataFrame contains columns with dtype datetime64[ns] "
11245+
"or timedelta64[ns], which are not supported for cov."
11246+
)
11247+
raise TypeError(msg)
1124211248
cols = data.columns
1124311249
idx = cols.copy()
1124411250
mat = data.to_numpy(dtype=float, na_value=np.nan, copy=False)

0 commit comments

Comments
 (0)