rename(self, name, inplace=False)
Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex.
Name(s) to set.
Modifies the object directly, instead of creating a new Index or MultiIndex.
The same type as the caller or None if inplace=True
.
Alter Index or MultiIndex name.
Index.set_names
Able to set new names partially and by level.
>>> idx = pd.Index(['A', 'C', 'A', 'B'], name='score')This example is valid syntax, but we were not able to check execution
... idx.rename('grade') Index(['A', 'C', 'A', 'B'], dtype='object', name='grade')
>>> idx = pd.MultiIndex.from_product([['python', 'cobra'],This example is valid syntax, but we were not able to check execution
... [2018, 2019]],
... names=['kind', 'year'])
... idx MultiIndex([('python', 2018), ('python', 2019), ( 'cobra', 2018), ( 'cobra', 2019)], names=['kind', 'year'])
>>> idx.rename(['species', 'year']) MultiIndex([('python', 2018), ('python', 2019), ( 'cobra', 2018), ( 'cobra', 2019)], names=['species', 'year'])This example is valid syntax, but we were not able to check execution
>>> idx.rename('species') Traceback (most recent call last): TypeError: Must pass list-like as `names`.See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.generic.NDFrame.rename_axis
pandas.core.generic.NDFrame._set_axis_name
pandas.core.indexes.base.Index.set_names
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them