# xarray.CFTimeIndex.symmetric_difference

#### CFTimeIndex.symmetric_difference(other, result_name=None, sort=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L3487-L3582)

Compute the symmetric difference of two Index objects.

* **Parameters:**
  * **other** ([`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index) or [array-like](https://numpy.org/doc/stable/glossary.html#term-array_like)) – Index or an array-like object with elements to compute the symmetric
    difference with the original Index.
  * **result_name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – A string representing the name of the resulting Index, if desired.
  * **sort** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *default* [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Whether to sort the resulting index. By default, the
    values are attempted to be sorted, but any TypeError from
    incomparable elements is caught by pandas.
    * None : Attempt to sort the result, but catch any TypeErrors
      from comparing incomparable elements.
    * False : Do not sort the result.
    * True : Sort the result (which may raise TypeError).
* **Returns:**
  [`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index) – Returns a new Index object containing elements that appear in either the
  original Index or the other Index, but not both.

#### SEE ALSO
`Index.difference`
: Return a new Index with elements of index not in other.

`Index.union`
: Form the union of two Index objects.

`Index.intersection`
: Form the intersection of two Index objects.

### Notes

`symmetric_difference` contains elements that appear in either
`idx1` or `idx2` but not both. Equivalent to the Index created by
`idx1.difference(idx2) | idx2.difference(idx1)` with duplicates
dropped.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('7a451b1d-d210-42c3-a883-f166f7adf6a9','d5ea0288-df6a-4431-9ff6-113ac2ec87af','08cc36f1-86cb-4b55-bfd4-1f5ba1edc14c','../lite/tree/../notebooks/index.html?path=9a808a92_c2f3_4382_a65e_19b79d75fa24.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> idx1 = pd.Index([1, 2, 3, 4])
>>> idx2 = pd.Index([2, 3, 4, 5])
>>> idx1.symmetric_difference(idx2)
Index([1, 5], dtype='int64')
```

<div id="08cc36f1-86cb-4b55-bfd4-1f5ba1edc14c" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('7a451b1d-d210-42c3-a883-f166f7adf6a9','08cc36f1-86cb-4b55-bfd4-1f5ba1edc14c')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('7a451b1d-d210-42c3-a883-f166f7adf6a9','08cc36f1-86cb-4b55-bfd4-1f5ba1edc14c')">Open In Tab</button></div><div id="d5ea0288-df6a-4431-9ff6-113ac2ec87af" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
