xdas.coordinates.Coordinate.to_index#

Coordinate.to_index(item, method=None, endpoint=True)[source]#

Convert a label-based selector to an integer index or slice.

Parameters:
  • item (label, slice, or array-like) – Selector to resolve.

  • method ({None, "nearest", "ffill", "bfill"}, optional) – How to resolve item when it does not match a label exactly. None (default) requires an exact match. "nearest" selects the closest label. "ffill" selects the last label ≤ item; "bfill" selects the first label ≥ item. Ignored when item is a slice.

  • endpoint (bool, optional) – Whether to include the stop of a slice. Default True.

Return type:

int, array of ints or slice