# xarray.CFTimeIndex.drop_duplicates

#### CFTimeIndex.drop_duplicates(, keep='first')[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L2854-L2904)

Return Index with duplicate values removed.

* **Parameters:**
  **keep** (`{'first', 'last', ``False`}\`\`, *default* `'first'`) –
  - ‘first’ : Drop duplicates except for the first occurrence.
  - ‘last’ : Drop duplicates except for the last occurrence.
  - `False` : Drop all duplicates.
* **Returns:**
  [`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index) – A new Index object with the duplicate values removed.

#### SEE ALSO
`Series.drop_duplicates`
: Equivalent method on Series.

`DataFrame.drop_duplicates`
: Equivalent method on DataFrame.

`Index.duplicated`
: Related method on Index, indicating duplicate Index values.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('a62eece0-74bf-4a9d-a1a7-e5f2e8881bdc','128090d9-e2b6-4293-99df-ee805236d06e','61fe8d23-f021-49fc-82ed-1704aa87768c','../lite/tree/../notebooks/index.html?path=73cd41c5_e91d_46aa_aa3c_4fdbc37c8113.ipynb','None')">Try it in your browser!</button></div>

Generate a pandas.Index with duplicate values.

```pycon
>>> idx = pd.Index(["llama", "cow", "llama", "beetle", "llama", "hippo"])
```

The keep parameter controls  which duplicate values are removed.
The value ‘first’ keeps the first occurrence for each
set of duplicated entries. The default value of keep is ‘first’.

```pycon
>>> idx.drop_duplicates(keep="first")
Index(['llama', 'cow', 'beetle', 'hippo'], dtype='str')
```

The value ‘last’ keeps the last occurrence for each set of duplicated
entries.

```pycon
>>> idx.drop_duplicates(keep="last")
Index(['cow', 'beetle', 'llama', 'hippo'], dtype='str')
```

The value `False` discards all sets of duplicated entries.

```pycon
>>> idx.drop_duplicates(keep=False)
Index(['cow', 'beetle', 'hippo'], dtype='str')
```

<div id="61fe8d23-f021-49fc-82ed-1704aa87768c" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('a62eece0-74bf-4a9d-a1a7-e5f2e8881bdc','61fe8d23-f021-49fc-82ed-1704aa87768c')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('a62eece0-74bf-4a9d-a1a7-e5f2e8881bdc','61fe8d23-f021-49fc-82ed-1704aa87768c')">Open In Tab</button></div><div id="128090d9-e2b6-4293-99df-ee805236d06e" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
