# xarray.DataArray.str.join

#### DataArray.str.join(dim=None, sep='')[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L526-L595)

Concatenate strings in a DataArray along a particular dimension.

An optional separator sep can also be specified. If sep is
array-like, it is broadcast against the array and applied elementwise.

* **Parameters:**
  * **dim** ([hashable](../user-guide/terminology.html.md#term-name), *optional*) – Dimension along which the strings should be concatenated.
    Only one dimension is allowed at a time.
    Optional for 0D or 1D DataArrays, required for multidimensional DataArrays.
  * **sep** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [array-like](https://numpy.org/doc/stable/glossary.html#term-array_like), *default*: `""```) – Separator to use between strings.
    It is broadcast in the same way as the other input strings.
    If array-like, its dimensions will be placed at the end of the output array dimensions.
* **Returns:**
  **joined** (`same type as values`)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('9cdd4103-19e6-4641-bcab-2271465dd189','de1f17d2-cf76-4b04-ad1b-e5c11f8e995f','93056ce5-6403-4b9c-ad77-6a8dab944b3f','../lite/tree/../notebooks/index.html?path=47993a29_d4bb_4588_ba2f_4f8f25f92a69.ipynb','None')">Try it in your browser!</button></div>

Create an array

```pycon
>>> values = xr.DataArray(
...     [["a", "bab", "abc"], ["abcd", "", "abcdef"]],
...     dims=["X", "Y"],
... )
```

Determine the separator

```pycon
>>> seps = xr.DataArray(
...     ["-", "_"],
...     dims=["ZZ"],
... )
```

Join the strings along a given dimension

```pycon
>>> values.str.join(dim="Y", sep=seps)
<xarray.DataArray (X: 2, ZZ: 2)> Size: 192B
array([['a-bab-abc', 'a_bab_abc'],
       ['abcd--abcdef', 'abcd__abcdef']], dtype='<U12')
Dimensions without coordinates: X, ZZ
```

<div id="93056ce5-6403-4b9c-ad77-6a8dab944b3f" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9cdd4103-19e6-4641-bcab-2271465dd189','93056ce5-6403-4b9c-ad77-6a8dab944b3f')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9cdd4103-19e6-4641-bcab-2271465dd189','93056ce5-6403-4b9c-ad77-6a8dab944b3f')">Open In Tab</button></div><div id="de1f17d2-cf76-4b04-ad1b-e5c11f8e995f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

#### SEE ALSO
[`pandas.Series.str.join`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.join.html#pandas.Series.str.join), [`str.join`](https://docs.python.org/3/builtins/stdtypes.html#str.join)
