# xarray.core.accessor_str.StringAccessor.join

#### StringAccessor.join(dim=None, sep='')[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L546-L614)

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`)

#### 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)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('ffb16700-a662-436c-bb69-4d88f7d0e106','da4fad70-ebd8-428a-827f-3e8f154181e2','38d897dc-e18e-4430-a477-35f45dcf52a3','../lite/tree/../notebooks/index.html?path=d3aa3798_b7be_4d60_9334_c2d1fecd3ece.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="38d897dc-e18e-4430-a477-35f45dcf52a3" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('ffb16700-a662-436c-bb69-4d88f7d0e106','38d897dc-e18e-4430-a477-35f45dcf52a3')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('ffb16700-a662-436c-bb69-4d88f7d0e106','38d897dc-e18e-4430-a477-35f45dcf52a3')">Open In Tab</button></div><div id="da4fad70-ebd8-428a-827f-3e8f154181e2" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
