remove_unused_levels(self) -> 'MultiIndex'
Unused level(s) means levels that are not expressed in the labels. The resulting MultiIndex will have the same outward appearance, meaning the same .values and ordering. It will also be .equals() to the original.
Create new MultiIndex from current that removes unused levels.
>>> mi = pd.MultiIndex.from_product([range(2), list('ab')])This example is valid syntax, but we were not able to check execution
... mi MultiIndex([(0, 'a'), (0, 'b'), (1, 'a'), (1, 'b')], )
>>> mi[2:] MultiIndex([(1, 'a'), (1, 'b')], )
The 0 from the first level is not represented and can be removed
This example is valid syntax, but we were not able to check execution>>> mi2 = mi[2:].remove_unused_levels()See :
... mi2.levels FrozenList([[1], ['a', 'b']])
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.indexing._IndexSlice
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