def find_last_value(self, value: ScalarLike, closest: bool = False) -> int: """ Returns offset of last value that matches. For monotonic columns, returns the offset of the last smaller value if closest=True. """ value = to_cudf_compatible_scalar(value) if not pd.api.types.is_number(value): raise ValueError("Expected a numeric value") found = 0 if len(self): found = cudautils.find_last( self.data_array_view, value, mask=self.mask, ) if found == -1 and self.is_monotonic and closest: if value < self.min(): found = -1 elif value > self.max(): found = len(self) - 1 else: found = cudautils.find_last( self.data_array_view, value, mask=self.mask, compare="lt", ) if found == -1: raise ValueError("value not found") elif found == -1: raise ValueError("value not found") return found
def find_last_value(self, value, closest=False): """ Returns offset of last value that matches. For monotonic columns, returns the offset of the last smaller value if closest=True. """ found = 0 if len(self): found = cudautils.find_last( self.data_array_view, value, mask=self.mask, ) if found == -1 and self.is_monotonic and closest: if value < self.min(): found = -1 elif value > self.max(): found = len(self) - 1 else: found = cudautils.find_last( self.data_array_view, value, mask=self.mask, compare="lt", ) if found == -1: raise ValueError("value not found") elif found == -1: raise ValueError("value not found") return found
def find_last_value(self, value): """ Returns offset of last value that matches. For monotonic columns, returns the offset of the last smaller value. """ found = cudautils.find_last(self.data.mem, value) if found == -1 and self.is_monotonic: if value < self.min(): found = -1 elif value > self.max(): found = len(self) - 1 else: found = cudautils.find_last(self.data.mem, value, compare="lt") if found == -1: raise ValueError("value not found") elif found == -1: raise ValueError("value not found") return found
def find_last_value(self, value): """ Returns offset of last value that matches """ found = cudautils.find_last( self.data.mem, value) if found == -1: raise ValueError('value not found') return found