# 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('7ee0496b-52ca-47a9-9d1d-79709b56b11d','2f9c13c2-5cc7-4a42-984e-be277370145c','82345b13-c1c8-4c84-8d09-8b1cdd4d64bc','../lite/tree/../notebooks/index.html?path=ee9d9db9_6ef0_42ba_b3af_0497e8b96770.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="82345b13-c1c8-4c84-8d09-8b1cdd4d64bc" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('7ee0496b-52ca-47a9-9d1d-79709b56b11d','82345b13-c1c8-4c84-8d09-8b1cdd4d64bc')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('7ee0496b-52ca-47a9-9d1d-79709b56b11d','82345b13-c1c8-4c84-8d09-8b1cdd4d64bc')">Open In Tab</button></div><div id="2f9c13c2-5cc7-4a42-984e-be277370145c" 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)
