# xarray.CFTimeIndex.set_names

#### CFTimeIndex.set_names(names, , level=None, inplace=False)[[source]](https://github.com/pydata/xarray/blob/main/xarray/../.pixi/envs/doc/lib/python3.14/site-packages/pandas/core/indexes/base.py#L1957-L2054)

Set Index or MultiIndex name.

Able to set new names partially and by level.

* **Parameters:**
  * **names** (`Hashable` or `a sequence` of `the previous` or `dict-like for MultiIndex`) – Name(s) to set.
  * **level** ([`int`](https://docs.python.org/3/builtins/functions.html#int), `Hashable` or `a sequence` of `the previous`, *optional*) – If the index is a MultiIndex and names is not dict-like, level(s) to set
    (None for all levels). Otherwise level must be None.
  * **inplace** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default* [`False`](https://docs.python.org/3/builtins/constants.html#False)) – Modifies the object directly, instead of creating a new Index or
    MultiIndex.
* **Returns:**
  [`Index`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.html#pandas.Index) or [`None`](https://docs.python.org/3/builtins/constants.html#None) – The same type as the caller or None if `inplace=True`.

#### SEE ALSO
[`Index.rename`](xarray.Index.rename.html.md#xarray.Index.rename)
: Able to set new names without level.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('9fb42847-aa25-443a-8160-a5a0dfa91213','6f47ebce-7603-4c37-9ddc-d4190b6969de','09b27064-5bd8-45a0-8267-7e009b166fb9','../lite/tree/../notebooks/index.html?path=e9aa71d1_68d2_45c9_96d2_0430e132b6da.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> idx = pd.Index([1, 2, 3, 4])
>>> idx
Index([1, 2, 3, 4], dtype='int64')
>>> idx.set_names("quarter")
Index([1, 2, 3, 4], dtype='int64', name='quarter')
```

```pycon
>>> idx = pd.MultiIndex.from_product([["python", "cobra"], [2018, 2019]])
>>> idx
MultiIndex([('python', 2018),
            ('python', 2019),
            ( 'cobra', 2018),
            ( 'cobra', 2019)],
           )
>>> idx = idx.set_names(["kind", "year"])
>>> idx.set_names("species", level=0)
MultiIndex([('python', 2018),
            ('python', 2019),
            ( 'cobra', 2018),
            ( 'cobra', 2019)],
           names=['species', 'year'])
```

When renaming levels with a dict, levels can not be passed.

```pycon
>>> idx.set_names({"kind": "snake"})
MultiIndex([('python', 2018),
            ('python', 2019),
            ( 'cobra', 2018),
            ( 'cobra', 2019)],
           names=['snake', 'year'])
```

<div id="09b27064-5bd8-45a0-8267-7e009b166fb9" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('9fb42847-aa25-443a-8160-a5a0dfa91213','09b27064-5bd8-45a0-8267-7e009b166fb9')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('9fb42847-aa25-443a-8160-a5a0dfa91213','09b27064-5bd8-45a0-8267-7e009b166fb9')">Open In Tab</button></div><div id="6f47ebce-7603-4c37-9ddc-d4190b6969de" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
