def asof_locs(self, where, mask):
where_idx = where<EOL>if isinstance(where_idx, DatetimeIndex):<EOL><INDENT>where_idx = PeriodIndex(where_idx.values, freq=self.freq)<EOL><DEDENT>locs = self._ndarray_values[mask].searchsorted(<EOL>where_idx._ndarray_values, side='<STR_LIT:right>')<EOL>locs = np.where(locs > <NUM_LIT:0>, locs - <NUM_LIT:1>, <NUM_LIT:0>)<EOL>result = np.arange(len(self))[mask].take(locs)<EOL>first = mask.argmax()<EOL>result[(locs == <NUM_LIT:0>) & (where_idx._ndarray_values <<EOL>self._ndarray_values[first])] = -<NUM_LIT:1><EOL>return result<EOL>
where : array of timestamps
mask : array of booleans where data is not NA