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)
| 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, |