map_values_to_nearest_index_irregular_grid#
- rojak.core.indexing.map_values_to_nearest_index_irregular_grid(series, coordinate, *, tie_breaker=NearestTieBreakConvention.LOWER)[source]#
Compute the closest index in
coordinatethat each value inseriescorresponds toUnlike
map_values_to_nearest_coordinate_index(), this does not requirecoordinateto be a regular grid or even sorted. Seenearest_index()for details, including how ties are broken.- Parameters:
series (dd.Series | pd.Series) – Data which corresponds to a given value in the coordinate array and needs to be mapped to the closest index in the coordinate array
coordinate (NDArray) – 1D array which is to be indexed into
tie_breaker (NearestTieBreakConvention)
- Returns:
Array of the closest index in
coordinatethat each value inseriesmaps to. Ifseriesis a dask series, this is a lazy dask array.- Return type:
da.Array | NDArray
>>> import pandas as pd >>> map_values_to_nearest_index_irregular_grid(pd.Series([1.0, 12.0, 27.0]), np.array([10.0, 0.0, 30.0, 20.0])) array([1, 0, 2])