# xarray.core.accessor_str.StringAccessor.cat

#### StringAccessor.cat(\*others, sep='')[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L445-L524)

Concatenate strings elementwise in the DataArray with other strings.

The other strings can either be string scalars or other array-like.
Dimensions are automatically broadcast together.

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

* **Parameters:**
  * **\*others** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [array-like](https://numpy.org/doc/stable/glossary.html#term-array_like) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Strings or array-like of strings to concatenate elementwise with
    the current DataArray.
  * **sep** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [array-like](https://numpy.org/doc/stable/glossary.html#term-array_like) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *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:**
  **concatenated** (`same type as values`)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('0111ad4a-ceef-4025-9433-a7e48411a637','eafa9f8d-262f-4617-bf67-a21b62f2dabb','f2cca09c-1759-4823-ad56-f9dd8ea65fd0','../lite/tree/../notebooks/index.html?path=04d50c61_5ea4_407b_af13_8ca279a1328b.ipynb','None')">Try it in your browser!</button></div>

Create a string array

```pycon
>>> myarray = xr.DataArray(
...     ["11111", "4"],
...     dims=["X"],
... )
```

Create some arrays to concatenate with it

```pycon
>>> values_1 = xr.DataArray(
...     ["a", "bb", "cccc"],
...     dims=["Y"],
... )
>>> values_2 = np.array(3.4)
>>> values_3 = ""
>>> values_4 = np.array("test", dtype=np.str_)
```

Determine the separator to use

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

Concatenate the arrays using the separator

```pycon
>>> myarray.str.cat(values_1, values_2, values_3, values_4, sep=seps)
<xarray.DataArray (X: 2, Y: 3, ZZ: 2)> Size: 1kB
array([[['11111 a 3.4  test', '11111, a, 3.4, , test'],
        ['11111 bb 3.4  test', '11111, bb, 3.4, , test'],
        ['11111 cccc 3.4  test', '11111, cccc, 3.4, , test']],

       [['4 a 3.4  test', '4, a, 3.4, , test'],
        ['4 bb 3.4  test', '4, bb, 3.4, , test'],
        ['4 cccc 3.4  test', '4, cccc, 3.4, , test']]], dtype='<U24')
Dimensions without coordinates: X, Y, ZZ
```

<div id="f2cca09c-1759-4823-ad56-f9dd8ea65fd0" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('0111ad4a-ceef-4025-9433-a7e48411a637','f2cca09c-1759-4823-ad56-f9dd8ea65fd0')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('0111ad4a-ceef-4025-9433-a7e48411a637','f2cca09c-1759-4823-ad56-f9dd8ea65fd0')">Open In Tab</button></div><div id="eafa9f8d-262f-4617-bf67-a21b62f2dabb" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

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