Skip to content

Commit 8b77ed2

Browse files
committed
BUG: Remove special-casing for Python date objects in DatetimeIndex
1 parent d8379c3 commit 8b77ed2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pandas/core/indexes/base.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from __future__ import annotations
22

33
from collections import abc
4-
from datetime import (
5-
datetime,
6-
)
4+
from datetime import datetime
75
import functools
86
from itertools import zip_longest
97
import operator
@@ -6305,14 +6303,26 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
63056303
return dtype.kind == "b"
63066304
elif is_numeric_dtype(self.dtype):
63076305
return is_numeric_dtype(dtype)
6308-
# GH#62158
63096306
elif isinstance(dtype, ArrowDtype):
6307+
# GH#62158
63106308
import pyarrow as pa
63116309

63126310
pa_dtype = dtype.pyarrow_dtype
63136311
if dtype.kind != "M":
63146312
if self.dtype.kind == "m" and pa.types.is_duration(pa_dtype):
63156313
return True
6314+
if is_string_dtype(self.dtype) and (
6315+
pa.types.is_string(pa_dtype) or pa.types.is_large_string(pa_dtype)
6316+
):
6317+
return True
6318+
if self.dtype.kind == "b" and pa.types.is_boolean(pa_dtype):
6319+
return True
6320+
if is_numeric_dtype(self.dtype) and (
6321+
pa.types.is_integer(pa_dtype) or pa.types.is_floating(pa_dtype)
6322+
):
6323+
return True
6324+
if is_object_dtype(self.dtype):
6325+
return True
63166326
return False
63176327
if self.dtype.kind != "M":
63186328
return False

0 commit comments

Comments
 (0)