MCPcopy Index your code
hub / github.com/pydata/xarray / index

Method index

xarray/core/accessor_str.py:1793–1842  ·  view source on GitHub ↗

Return lowest or highest indexes in each strings where the substring is fully contained between [start:end]. This is the same as ``str.find`` except instead of returning -1, it raises a ValueError when the substring is not found. If `start`, `end`, or 'sub`

(
        self,
        sub: str | bytes | Any,
        start: int | Any = 0,
        end: int | Any = None,
        side: str = "left",
    )

Source from the content-addressed store, hash-verified

1791 return self.find(sub, start=start, end=end, side="right")
1792
1793 def index(
1794 self,
1795 sub: str | bytes | Any,
1796 start: int | Any = 0,
1797 end: int | Any = None,
1798 side: str = "left",
1799 ) -> T_DataArray:
1800 """
1801 Return lowest or highest indexes in each strings where the substring is
1802 fully contained between [start:end]. This is the same as
1803 ``str.find`` except instead of returning -1, it raises a ValueError
1804 when the substring is not found.
1805
1806 If `start`, `end`, or 'sub` is array-like, they are broadcast
1807 against the array and applied elementwise.
1808
1809 Parameters
1810 ----------
1811 sub : str or array-like of str
1812 Substring being searched.
1813 If array-like, it is broadcast.
1814 start : int or array-like of int
1815 Left edge index.
1816 If array-like, it is broadcast.
1817 end : int or array-like of int
1818 Right edge index.
1819 If array-like, it is broadcast.
1820 side : {"left", "right"}, default: "left"
1821 Starting side for search.
1822
1823 Returns
1824 -------
1825 found : array of int
1826
1827 Raises
1828 ------
1829 ValueError
1830 substring is not found
1831 """
1832 sub = self._stringify(sub)
1833
1834 if side == "left":
1835 method = "index"
1836 elif side == "right":
1837 method = "rindex"
1838 else: # pragma: no cover
1839 raise ValueError("Invalid side")
1840
1841 func = lambda x, isub, istart, iend: getattr(x, method)(isub, istart, iend)
1842 return self._apply(func=func, func_args=(sub, start, end), dtype=int)
1843
1844 def rindex(
1845 self,

Callers 10

rindexMethod · 0.95
_check_higher_resolutionFunction · 0.45
parse_ordered_dimsFunction · 0.45
_path_to_ancestorMethod · 0.45
_get_axis_numMethod · 0.45
as_integer_or_noneFunction · 0.45
_convert_scalarMethod · 0.45
_coord_sort_keyFunction · 0.45
broadcast_compat_dataFunction · 0.45

Calls 2

_stringifyMethod · 0.95
_applyMethod · 0.95

Tested by

no test coverage detected