File tree Expand file tree Collapse file tree 3 files changed +32
-13
lines changed Expand file tree Collapse file tree 3 files changed +32
-13
lines changed Original file line number Diff line number Diff line change 7373 NDArrayBackedExtensionArray ,
7474 ravel_compat ,
7575)
76- from pandas .core .arrays .arrow .array import ArrowExtensionArray
7776from pandas .core .base import (
7877 ExtensionArray ,
7978 NoNewAttributesMixin ,
@@ -484,18 +483,6 @@ def __init__(
484483 )
485484
486485 else :
487- if isinstance (values , ArrowExtensionArray ):
488- from pandas .api .types import (
489- is_datetime64_any_dtype ,
490- is_timedelta64_dtype ,
491- )
492-
493- cat_dtype = dtype .categories .dtype
494- if is_datetime64_any_dtype (cat_dtype ) or is_timedelta64_dtype (
495- cat_dtype
496- ):
497- values = values .to_numpy ()
498-
499486 codes = _get_codes_for_values (values , dtype .categories )
500487
501488 if null_mask .any ():
Original file line number Diff line number Diff line change @@ -3674,6 +3674,16 @@ def get_indexer(
36743674 orig_target = target
36753675 target = self ._maybe_cast_listlike_indexer (target )
36763676
3677+ from pandas .api .types import is_timedelta64_dtype
3678+ if (
3679+ self .dtype == "string[pyarrow]" and is_timedelta64_dtype (target .dtype )
3680+ ) or (
3681+ target .dtype == "string[pyarrow]" and is_timedelta64_dtype (self .dtype )
3682+ ):
3683+ from pandas .core .arrays .timedeltas import sequence_to_td64ns
3684+ data , freq = sequence_to_td64ns (target , copy = False , unit = None )
3685+ target = type (target )(data )
3686+
36773687 self ._check_indexing_method (method , limit , tolerance )
36783688
36793689 if not self ._index_as_unique :
@@ -6273,6 +6283,16 @@ def _find_common_type_compat(self, target) -> DtypeObj:
62736283 ):
62746284 return _dtype_obj
62756285
6286+ # from pandas.api.types import is_timedelta64_dtype
6287+ # from pandas.core.arrays.timedeltas import sequence_to_td64ns
6288+
6289+ # if (
6290+ # self.dtype == "string[pyarrow]" and is_timedelta64_dtype(target_dtype)
6291+ # ) or (
6292+ # target_dtype == "string[pyarrow]" and is_timedelta64_dtype(self.dtype)
6293+ # ):
6294+ # return np.dtype("m8[ns]")
6295+
62766296 dtype = find_result_type (self .dtype , target )
62776297 dtype = common_dtype_categorical_compat ([self , target ], dtype )
62786298 return dtype
Original file line number Diff line number Diff line change @@ -384,6 +384,18 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
384384 if self .tz is not None :
385385 # If we have tz, we can compare to tzaware
386386 return isinstance (dtype , DatetimeTZDtype )
387+
388+ from pandas import ArrowDtype
389+
390+ if isinstance (dtype , ArrowDtype ):
391+ import pyarrow as pa
392+
393+ return (
394+ pa .types .is_date32 (dtype .pyarrow_dtype )
395+ or pa .types .is_date64 (dtype .pyarrow_dtype )
396+ or pa .types .is_timestamp (dtype .pyarrow_dtype )
397+ )
398+
387399 # if we dont have tz, we can only compare to tznaive
388400 return lib .is_np_dtype (dtype , "M" )
389401
You can’t perform that action at this time.
0 commit comments