modin.pandas.Index.set_names

Index.set_names(names: Any, level: Any = None, inplace: bool = False) Index | None[source]

Set Index name.

Able to set new names partially and by level.

Parameters:
  • names (label or list of label or dict-like for MultiIndex) – Name(s) to set.

  • level (int, label or list of int or label, optional) –

  • inplace (bool, default False) – Modifies the object directly, instead of creating a new Index.

Returns:

The same type as the caller or None if inplace=True.

Return type:

Index or None

Examples

>>> 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')
Copy