112
112
)
113
113
114
114
from pandas .core import (
115
+ algorithms ,
115
116
nanops ,
116
117
ops ,
117
118
)
118
- from pandas .core .algorithms import (
119
- checked_add_with_arr ,
120
- isin ,
121
- mode ,
122
- unique1d ,
123
- )
124
119
from pandas .core .arraylike import OpsMixin
125
120
from pandas .core .arrays ._mixins import (
126
121
NDArrayBackedExtensionArray ,
@@ -805,14 +800,14 @@ def isin(self, values) -> npt.NDArray[np.bool_]:
805
800
pass
806
801
807
802
elif "mixed" in inferred :
808
- return isin (self .astype (object ), values )
803
+ return algos . isin (self .astype (object ), values )
809
804
else :
810
805
return np .zeros (self .shape , dtype = bool )
811
806
812
807
try :
813
808
values = type (self )._from_sequence (values )
814
809
except ValueError :
815
- return isin (self .astype (object ), values )
810
+ return algos . isin (self .astype (object ), values )
816
811
817
812
if self .dtype .kind in ["m" , "M" ]:
818
813
self = cast ("DatetimeArray | TimedeltaArray" , self )
@@ -824,7 +819,7 @@ def isin(self, values) -> npt.NDArray[np.bool_]:
824
819
# Includes tzawareness mismatch and IncompatibleFrequencyError
825
820
return np .zeros (self .shape , dtype = bool )
826
821
827
- return isin (self .asi8 , values .asi8 )
822
+ return algos . isin (self .asi8 , values .asi8 )
828
823
829
824
# ------------------------------------------------------------------
830
825
# Null Handling
@@ -993,7 +988,7 @@ def _is_monotonic_decreasing(self) -> bool:
993
988
994
989
@property
995
990
def _is_unique (self ) -> bool :
996
- return len (unique1d (self .asi8 .ravel ("K" ))) == self .size
991
+ return len (algos . unique1d (self .asi8 .ravel ("K" ))) == self .size
997
992
998
993
# ------------------------------------------------------------------
999
994
# Arithmetic Methods
@@ -1125,7 +1120,7 @@ def _add_datetimelike_scalar(self, other) -> DatetimeArray:
1125
1120
self = cast ("TimedeltaArray" , self )
1126
1121
1127
1122
other_i8 , o_mask = self ._get_i8_values_and_mask (other )
1128
- result = checked_add_with_arr (
1123
+ result = algos . checked_add_with_arr (
1129
1124
self .asi8 , other_i8 , arr_mask = self ._isnan , b_mask = o_mask
1130
1125
)
1131
1126
res_values = result .view (f"M8[{ self .unit } ]" )
@@ -1188,7 +1183,7 @@ def _sub_datetimelike(self, other: Timestamp | DatetimeArray) -> TimedeltaArray:
1188
1183
raise type (err )(new_message ) from err
1189
1184
1190
1185
other_i8 , o_mask = self ._get_i8_values_and_mask (other )
1191
- res_values = checked_add_with_arr (
1186
+ res_values = algos . checked_add_with_arr (
1192
1187
self .asi8 , - other_i8 , arr_mask = self ._isnan , b_mask = o_mask
1193
1188
)
1194
1189
res_m8 = res_values .view (f"timedelta64[{ self .unit } ]" )
@@ -1254,7 +1249,7 @@ def _add_timedeltalike(self, other: Timedelta | TimedeltaArray):
1254
1249
self = cast ("DatetimeArray | TimedeltaArray" , self )
1255
1250
1256
1251
other_i8 , o_mask = self ._get_i8_values_and_mask (other )
1257
- new_values = checked_add_with_arr (
1252
+ new_values = algos . checked_add_with_arr (
1258
1253
self .asi8 , other_i8 , arr_mask = self ._isnan , b_mask = o_mask
1259
1254
)
1260
1255
res_values = new_values .view (self ._ndarray .dtype )
@@ -1309,7 +1304,7 @@ def _sub_periodlike(self, other: Period | PeriodArray) -> npt.NDArray[np.object_
1309
1304
self ._check_compatible_with (other )
1310
1305
1311
1306
other_i8 , o_mask = self ._get_i8_values_and_mask (other )
1312
- new_i8_data = checked_add_with_arr (
1307
+ new_i8_data = algos . checked_add_with_arr (
1313
1308
self .asi8 , - other_i8 , arr_mask = self ._isnan , b_mask = o_mask
1314
1309
)
1315
1310
new_data = np .array ([self .freq .base * x for x in new_i8_data ])
@@ -1690,7 +1685,7 @@ def _mode(self, dropna: bool = True):
1690
1685
if dropna :
1691
1686
mask = self .isna ()
1692
1687
1693
- i8modes = mode (self .view ("i8" ), mask = mask )
1688
+ i8modes = algorithms . algos . mode (self .view ("i8" ), mask = mask )
1694
1689
npmodes = i8modes .view (self ._ndarray .dtype )
1695
1690
npmodes = cast (np .ndarray , npmodes )
1696
1691
return self ._from_backing_data (npmodes )
0 commit comments