AlloViz.AlloViz.Elements.Edges._set_axis_name

Edges._set_axis_name(name, axis: int | Literal['index', 'columns', 'rows'] = 0, inplace: bool = False, copy: bool | None = True)

Set the name(s) of the axis.

Parameters:
namestr or list of str

Name(s) to set.

axis{0 or ‘index’, 1 or ‘columns’}, default 0

The axis to set the label. The value 0 or ‘index’ specifies index, and the value 1 or ‘columns’ specifies columns.

inplacebool, default False

If True, do operation inplace and return None.

copy:

Whether to make a copy of the result.

Returns:
Series, DataFrame, or None

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

See also

DataFrame.rename

Alter the axis labels of DataFrame.

Series.rename

Alter the index labels or set the index name of Series.

Index.rename

Set the name of Index or MultiIndex.

Examples

>>> df = pd.DataFrame({"num_legs": [4, 4, 2]},
...                   ["dog", "cat", "monkey"])
>>> df
        num_legs
dog            4
cat            4
monkey         2
>>> df._set_axis_name("animal")
        num_legs
animal
dog            4
cat            4
monkey         2
>>> df.index = pd.MultiIndex.from_product(
...                [["mammal"], ['dog', 'cat', 'monkey']])
>>> df._set_axis_name(["type", "name"])
               num_legs
type   name
mammal dog        4
       cat        4
       monkey     2