# xarray.core.accessor_str.StringAccessor.swapcase

#### StringAccessor.swapcase()[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/accessor_str.py#L732-L754)

Convert strings in the array to be swapcased.

* **Returns:**
  **swapcased** (`same type as values`)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('d5d406ee-4875-4d5d-81df-4ad8ef9d9eff','d180cd47-b2c5-44e9-b386-634fe46e847a','f45ba538-a716-4cf7-a107-83d423e47145','../lite/tree/../notebooks/index.html?path=2bbaae0c_68ed_4a8f_9dac_898c95253376.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import xarray as xr
>>> da = xr.DataArray(["temperature", "PRESSURE", "HuMiDiTy"], dims="x")
>>> da
<xarray.DataArray (x: 3)> Size: 132B
array(['temperature', 'PRESSURE', 'HuMiDiTy'], dtype='<U11')
Dimensions without coordinates: x
>>> swapcased = da.str.swapcase()
>>> swapcased
<xarray.DataArray (x: 3)> Size: 132B
array(['TEMPERATURE', 'pressure', 'hUmIdItY'], dtype='<U11')
Dimensions without coordinates: x
```

<div id="f45ba538-a716-4cf7-a107-83d423e47145" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d5d406ee-4875-4d5d-81df-4ad8ef9d9eff','f45ba538-a716-4cf7-a107-83d423e47145')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d5d406ee-4875-4d5d-81df-4ad8ef9d9eff','f45ba538-a716-4cf7-a107-83d423e47145')">Open In Tab</button></div><div id="d180cd47-b2c5-44e9-b386-634fe46e847a" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
