Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bug cov nat #60898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: Improve error message for unsupported datetime and timedelta dty…
…pes in cov()
  • Loading branch information
fbourgey committed Mar 26, 2025
commit cff4f369af762b5adf1dca2a08d6f96f6c7dcbec
9 changes: 6 additions & 3 deletions 9 pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
is_sequence,
needs_i8_conversion,
pandas_dtype,
is_timedelta64_dtype,
is_datetime64_any_dtype,
)
from pandas.core.dtypes.concat import concat_compat
from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -11267,10 +11269,11 @@ def cov(
c -0.150812 0.191417 0.895202
"""
data = self._get_numeric_data() if numeric_only else self
if data.select_dtypes(include=[np.datetime64, np.timedelta64]).shape[1] > 0:
dtypes = [blk.dtype for blk in self._mgr.blocks]
if any(is_datetime64_any_dtype(d) or is_timedelta64_dtype(d) for d in dtypes):
fbourgey marked this conversation as resolved.
Show resolved Hide resolved
msg = (
"DataFrame contains columns with dtype datetime64[ns] "
"or timedelta64[ns], which are not supported for cov."
"DataFrame contains columns with dtype datetime64 "
"or timedelta64, which are not supported for cov."
)
raise TypeError(msg)
cols = data.columns
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.