11from __future__ import annotations
22
33from collections import abc
4- from datetime import datetime
4+ from datetime import (
5+ date ,
6+ datetime ,
7+ )
58import functools
69from itertools import zip_longest
710import operator
@@ -6288,6 +6291,18 @@ def _should_compare(self, other: Index) -> bool:
62886291 # respectively.
62896292 return False
62906293
6294+ # GH#62158
6295+ if (
6296+ self .dtype .kind == "M"
6297+ and isinstance (other , Index )
6298+ and other .dtype == _dtype_obj
6299+ and all (
6300+ isinstance (x , date ) and not isinstance (x , datetime )
6301+ for x in other ._values
6302+ )
6303+ ):
6304+ return False
6305+
62916306 dtype = _unpack_nested_dtype (other )
62926307 return (
62936308 self ._is_comparable_dtype (dtype )
@@ -6304,13 +6319,21 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
63046319 elif is_numeric_dtype (self .dtype ):
63056320 return is_numeric_dtype (dtype )
63066321 # GH#62158
6307- elif self .dtype .kind == "M" and dtype == object :
6308- return False
63096322 elif isinstance (dtype , ArrowDtype ):
63106323 import pyarrow as pa
63116324
63126325 pa_dtype = dtype .pyarrow_dtype
6313- if self .dtype .kind != "M" or dtype .kind != "M" :
6326+ if dtype .kind != "M" :
6327+ if self .dtype .kind == "b" :
6328+ return dtype .kind == "b"
6329+ if is_numeric_dtype (self .dtype ):
6330+ return pa .types .is_integer (pa_dtype ) or pa .types .is_floating (
6331+ pa_dtype
6332+ )
6333+ if self .dtype .kind == "m" and pa .types .is_duration (pa_dtype ):
6334+ return True
6335+ return False
6336+ if self .dtype .kind != "M" :
63146337 return False
63156338 if pa .types .is_date (pa_dtype ):
63166339 return False
0 commit comments