# xarray.core.accessor_str.StringAccessor.startswith

#### StringAccessor.startswith(pat)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L1187-L1222)

Test if the start 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`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Character sequence. Regular expressions are not accepted.
  If array-like, it is broadcast.
* **Returns:**
  **startswith** ([array](https://numpy.org/doc/stable/glossary.html#term-array) of [`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – An array of booleans indicating whether the given pattern matches
  the start of each string element.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('54d3ee85-6cdd-46db-80a0-154b68c734ea','29c64755-8952-457a-b079-d24bc2e445c7','4932a1ff-fcc5-4466-9ff6-2e46474f777a','../lite/tree/../notebooks/index.html?path=001ef6fa_3561_41e0_993e_906e11c20696.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> da = xr.DataArray(["$100", "£23", "100"], dims="x")
>>> da
<xarray.DataArray (x: 3)> Size: 48B
array(['$100', '£23', '100'], dtype='<U4')
Dimensions without coordinates: x
>>> startswith = da.str.startswith("$")
>>> startswith
<xarray.DataArray (x: 3)> Size: 3B
array([ True, False, False])
Dimensions without coordinates: x
```

<div id="4932a1ff-fcc5-4466-9ff6-2e46474f777a" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('54d3ee85-6cdd-46db-80a0-154b68c734ea','4932a1ff-fcc5-4466-9ff6-2e46474f777a')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('54d3ee85-6cdd-46db-80a0-154b68c734ea','4932a1ff-fcc5-4466-9ff6-2e46474f777a')">Open In Tab</button></div><div id="29c64755-8952-457a-b079-d24bc2e445c7" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
