# xarray.core.accessor_str.StringAccessor.startswith

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

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('96b06c85-d7ab-40c9-912c-1db956c18274','d5ee11ee-c238-4cd0-a33c-001235ebc67d','ab671be5-3071-4c26-b6a0-376ee79fd1c2','../lite/tree/../notebooks/index.html?path=4cc63634_54a1_4e23_8f5a_aaa52ba370e2.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="ab671be5-3071-4c26-b6a0-376ee79fd1c2" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('96b06c85-d7ab-40c9-912c-1db956c18274','ab671be5-3071-4c26-b6a0-376ee79fd1c2')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('96b06c85-d7ab-40c9-912c-1db956c18274','ab671be5-3071-4c26-b6a0-376ee79fd1c2')">Open In Tab</button></div><div id="d5ee11ee-c238-4cd0-a33c-001235ebc67d" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
