# xarray.DataArray.str.join

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

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('4d7b17e9-a316-4081-b1a9-d23c5b664c01','607a5eb7-56e7-4edf-bd09-55d9350bec07','522954bf-486a-423d-85ab-3fa4fddd4132','../lite/tree/../notebooks/index.html?path=9d0bfd69_5387_4a77_ab23_7e9f7292a9d1.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="522954bf-486a-423d-85ab-3fa4fddd4132" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('4d7b17e9-a316-4081-b1a9-d23c5b664c01','522954bf-486a-423d-85ab-3fa4fddd4132')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('4d7b17e9-a316-4081-b1a9-d23c5b664c01','522954bf-486a-423d-85ab-3fa4fddd4132')">Open In Tab</button></div><div id="607a5eb7-56e7-4edf-bd09-55d9350bec07" 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)
