ex.to_timestamp.html)
    * [ pandas.PeriodIndex.from_fields ](pandas.PeriodIndex.from_fields.html)
    * [ pandas.PeriodIndex.from_ordinals ](pandas.PeriodIndex.from_ordinals.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ Index objects ](../indexing.html)
  * pandas.MultiIndex 

#  pandas.MultiIndex  #

_ class  _ pandas.  MultiIndex  (  _ levels  =  None  _ , _ codes  =  None  _
, _ sortorder  =  None  _ , _ names  =  None  _ , _ dtype  =  None  _ , _ copy
=  False  _ , _ name  =  None  _ , _ verify_integrity  =  True  _ )  [
[source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/indexes/multi.py#L227-L4034) #

    

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

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.

See also

[ ` MultiIndex.from_arrays  `
](pandas.MultiIndex.from_arrays.html#pandas.MultiIndex.from_arrays
"pandas.MultiIndex.from_arrays")

    

Convert list of arrays to MultiIndex.

[ ` MultiIndex.from_product  `
](pandas.MultiIndex.from_product.html#pandas.MultiIndex.from_product
"pandas.MultiIndex.from_product")

    

Create a MultiIndex from the cartesian product of iterables.

[ ` MultiIndex.from_tuples  `
](pandas.MultiIndex.from_tuples.html#pandas.MultiIndex.from_tuples
"pandas.MultiIndex.from_tuples")

    

Convert list of tuples to a MultiIndex.

[ ` MultiIndex.from_frame  `
](pandas.MultiIndex.from_frame.html#pandas.MultiIndex.from_frame
"pandas.MultiIndex.from_frame")

    

Make a MultiIndex from a DataFrame.

[ ` Index  ` ](pandas.Index.html#pandas.Index "pandas.Index")

    

The base pandas Index type.

Notes

See the [ user guide ](https://pandas.pydata.org/pandas-
docs/stable/user_guide/advanced.html) for more.

Examples

A new ` MultiIndex  ` is typically constructed using one of the helper methods
[ ` MultiIndex.from_arrays()  `
](pandas.MultiIndex.from_arrays.html#pandas.MultiIndex.from_arrays
"pandas.MultiIndex.from_arrays") , [ ` MultiIndex.from_product()  `
](pandas.MultiIndex.from_product.html#pandas.MultiIndex.from_product
"pandas.MultiIndex.from_product") and [ ` MultiIndex.from_tuples()  `
](pandas.MultiIndex.from_tuples.html#pandas.MultiIndex.from_tuples
"pandas.MultiIndex.from_tuples") . For example (using ` .from_arrays  ` ):

    
    
    >>> 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.

Attributes

[ ` names  ` ](pandas.MultiIndex.names.html#pandas.MultiIndex.names "pandas.MultiIndex.names") |  Names of levels in MultiIndex.   
---|---  
[ ` levels  ` ](pandas.MultiIndex.levels.html#pandas.MultiIndex.levels "pandas.MultiIndex.levels") |  Levels of the MultiIndex.   
[ ` nlevels  ` ](pandas.MultiIndex.nlevels.html#pandas.MultiIndex.nlevels "pandas.MultiIndex.nlevels") |  Integer num