Skip to content

Commit 98a5061

Browse files
committed
Fix dtype match except [ps]
1 parent 6df540c commit 98a5061

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ def maybe_cast_to_datetime(value, dtype, errors="raise"):
10261026
)
10271027

10281028
if is_datetime64 and not is_dtype_equal(dtype, _NS_DTYPE):
1029-
if dtype.kind == "M":
1029+
if (dtype.kind == "M") and (dtype.name != "datetime64[ps]"):
10301030
if dtype.name == "datetime64":
10311031
raise ValueError(msg.format(dtype=dtype.name))
10321032
dtype = _NS_DTYPE
@@ -1044,7 +1044,7 @@ def maybe_cast_to_datetime(value, dtype, errors="raise"):
10441044
value = [value]
10451045

10461046
elif is_timedelta64 and not is_dtype_equal(dtype, _TD_DTYPE):
1047-
if dtype.kind == "m":
1047+
if (dtype.kind == "m") and (dtype.name != "timedelta64[ps]"):
10481048
if dtype.name == "timedelta64":
10491049
raise ValueError(msg.format(dtype=dtype.name))
10501050
dtype = _TD_DTYPE

0 commit comments

Comments
 (0)