pandas 1.4.2

AttributesMethodsNotesParametersBackRef

Attributes

names :
levels :
codes :
nlevels :
levshape :

Methods

Notes

See the :None:None:`user guide <https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html>` for more.

Parameters

levels : sequence of arrays

The unique labels for each level.

codes : sequence of arrays

Integers for each level designating which label at each location.

sortorder : optional int

Level of sortedness (must be lexicographically sorted by that level).

names : optional sequence of objects

Names for each of the index levels. (name is accepted for compat).

copy : bool, default False

Copy the meta-data.

verify_integrity : bool, default True

Check that the levels/codes are consistent and valid.

A multi-level, or hierarchical, index object for pandas objects.

See Also

Index

The base pandas Index type.

MultiIndex.from_arrays

Convert list of arrays to MultiIndex.

MultiIndex.from_frame

Make a MultiIndex from a DataFrame.

MultiIndex.from_product

Create a MultiIndex from the cartesian product of iterables.

MultiIndex.from_tuples

Convert list of tuples to a MultiIndex.

Examples

A new MultiIndex is typically constructed using one of the helper methods MultiIndex.from_arrays , MultiIndex.from_product and MultiIndex.from_tuples . For example (using .from_arrays ):

This example is valid syntax, but we were not able to check execution
>>> arrays = [[1, 1, 2, 2], ['red', 'blue', 'red', 'blue']]
... pd.MultiIndex.from_arrays(arrays, names=('number', 'color')) MultiIndex([(1, 'red'), (1, 'blue'), (2, 'red'), (2, 'blue')], names=['number', 'color'])

See further examples for how to construct a MultiIndex in the doc strings of the mentioned helper methods.

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.frame.DataFrame.count pandas.core.frame.DataFrame.reset_index pandas.core.indexes.multi.MultiIndex.isin pandas.core.frame.DataFrame.iterrows pandas.core.indexes.base.Index pandas.core.indexes.base.Index.isin

Local connectivity graph

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


File: /pandas/core/indexes/multi.py#209
type: <class 'type'>
Commit: