MCPcopy
hub / github.com/pydata/xarray / endswith

Method endswith

xarray/core/accessor_str.py:1193–1227  ·  view source on GitHub ↗

Test if the end of each string in the array matches a pattern. The pattern `pat` can either be a ``str`` or array-like of ``str``. If array-like, it will be broadcast and applied elementwise. Parameters ---------- pat : str Character seq

(self, pat: str | bytes | Any)

Source from the content-addressed store, hash-verified

1191 return self._apply(func=func, func_args=(pat,), dtype=bool)
1192
1193 def endswith(self, pat: str | bytes | Any) -> T_DataArray:
1194 """
1195 Test if the end of each string in the array matches a pattern.
1196
1197 The pattern `pat` can either be a ``str`` or array-like of ``str``.
1198 If array-like, it will be broadcast and applied elementwise.
1199
1200 Parameters
1201 ----------
1202 pat : str
1203 Character sequence. Regular expressions are not accepted.
1204 If array-like, it is broadcast.
1205
1206 Returns
1207 -------
1208 endswith : array of bool
1209 A Series of booleans indicating whether the given pattern matches
1210 the end of each string element.
1211
1212 Examples
1213 --------
1214 >>> da = xr.DataArray(["10C", "10c", "100F"], dims="x")
1215 >>> da
1216 <xarray.DataArray (x: 3)> Size: 48B
1217 array(['10C', '10c', '100F'], dtype='<U4')
1218 Dimensions without coordinates: x
1219 >>> endswith = da.str.endswith("C")
1220 >>> endswith
1221 <xarray.DataArray (x: 3)> Size: 3B
1222 array([ True, False, False])
1223 Dimensions without coordinates: x
1224 """
1225 pat = self._stringify(pat)
1226 func = lambda x, y: x.endswith(y)
1227 return self._apply(func=func, func_args=(pat,), dtype=bool)
1228
1229 def pad(
1230 self,

Callers 13

_new_to_legacy_freqFunction · 0.80
_legacy_to_new_freqFunction · 0.80
_open_scipy_netcdfFunction · 0.80
test_variable_repr_htmlFunction · 0.80
test_attribute_reprMethod · 0.80
test_starts_ends_withFunction · 0.80

Calls 2

_stringifyMethod · 0.95
_applyMethod · 0.95

Tested by 7

test_variable_repr_htmlFunction · 0.64
test_attribute_reprMethod · 0.64
test_starts_ends_withFunction · 0.64
test_empty_str_methodsFunction · 0.64