@@ -404,28 +404,17 @@ def __array_wrap__(self, result, context=None):
404
404
# cannot pass _simple_new as it is
405
405
return type (self )(result , freq = self .freq , name = self .name )
406
406
407
- def asof_locs (self , where , mask : np .ndarray ) -> np .ndarray :
407
+ def asof_locs (self , where : Index , mask : np .ndarray ) -> np .ndarray :
408
408
"""
409
409
where : array of timestamps
410
410
mask : array of booleans where data is not NA
411
411
"""
412
- where_idx = where
413
- if isinstance (where_idx , DatetimeIndex ):
414
- where_idx = PeriodIndex (where_idx ._values , freq = self .freq )
415
- elif not isinstance (where_idx , PeriodIndex ):
412
+ if isinstance (where , DatetimeIndex ):
413
+ where = PeriodIndex (where ._values , freq = self .freq )
414
+ elif not isinstance (where , PeriodIndex ):
416
415
raise TypeError ("asof_locs `where` must be DatetimeIndex or PeriodIndex" )
417
- elif where_idx .freq != self .freq :
418
- raise raise_on_incompatible (self , where_idx )
419
416
420
- locs = self .asi8 [mask ].searchsorted (where_idx .asi8 , side = "right" )
421
-
422
- locs = np .where (locs > 0 , locs - 1 , 0 )
423
- result = np .arange (len (self ))[mask ].take (locs )
424
-
425
- first = mask .argmax ()
426
- result [(locs == 0 ) & (where_idx .asi8 < self .asi8 [first ])] = - 1
427
-
428
- return result
417
+ return super ().asof_locs (where , mask )
429
418
430
419
@doc (Index .astype )
431
420
def astype (self , dtype , copy : bool = True , how = "start" ):
0 commit comments