# xarray.CFTimeIndex.drop_duplicates

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

Return Index with duplicate values removed.

The `keep` parameter controls which duplicate values are removed.
The original Index is not modified.

* **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('5454ffba-8d5c-4329-aea2-3aba5fe12680','1ff41cd1-8036-4b8d-95c6-bf7003216534','be37726b-013d-40b9-87b1-6ef8f9cc2ec6','../lite/tree/../notebooks/index.html?path=713786dc_6389_489c_9937_11f56a237616.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="be37726b-013d-40b9-87b1-6ef8f9cc2ec6" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('5454ffba-8d5c-4329-aea2-3aba5fe12680','be37726b-013d-40b9-87b1-6ef8f9cc2ec6')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('5454ffba-8d5c-4329-aea2-3aba5fe12680','be37726b-013d-40b9-87b1-6ef8f9cc2ec6')">Open In Tab</button></div><div id="1ff41cd1-8036-4b8d-95c6-bf7003216534" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
