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 73
73
NDArrayBackedExtensionArray ,
74
74
ravel_compat ,
75
75
)
76
- from pandas .core .arrays .arrow .array import ArrowExtensionArray
77
76
from pandas .core .base import (
78
77
ExtensionArray ,
79
78
NoNewAttributesMixin ,
@@ -484,18 +483,6 @@ def __init__(
484
483
)
485
484
486
485
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
-
499
486
codes = _get_codes_for_values (values , dtype .categories )
500
487
501
488
if null_mask .any ():
Original file line number Diff line number Diff line change @@ -3674,6 +3674,16 @@ def get_indexer(
3674
3674
orig_target = target
3675
3675
target = self ._maybe_cast_listlike_indexer (target )
3676
3676
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
+
3677
3687
self ._check_indexing_method (method , limit , tolerance )
3678
3688
3679
3689
if not self ._index_as_unique :
@@ -6273,6 +6283,16 @@ def _find_common_type_compat(self, target) -> DtypeObj:
6273
6283
):
6274
6284
return _dtype_obj
6275
6285
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
+
6276
6296
dtype = find_result_type (self .dtype , target )
6277
6297
dtype = common_dtype_categorical_compat ([self , target ], dtype )
6278
6298
return dtype
Original file line number Diff line number Diff line change @@ -384,6 +384,18 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
384
384
if self .tz is not None :
385
385
# If we have tz, we can compare to tzaware
386
386
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
+
387
399
# if we dont have tz, we can only compare to tznaive
388
400
return lib .is_np_dtype (dtype , "M" )
389
401
You can’t perform that action at this time.
0 commit comments