pyspark.pandas.MultiIndex.from_tuples#

static MultiIndex.from_tuples(tuples, sortorder=None, names=None)[source]#

Convert list of tuples to MultiIndex.

Parameters
tupleslist / sequence of tuple-likes

Each tuple is the index of one row/column.

sortorderint or None

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

nameslist / sequence of str, optional

Names for the levels in the index.

Returns
indexMultiIndex

Examples

>>> tuples = [(1, 'red'), (1, 'blue'),
...           (2, 'red'), (2, 'blue')]
>>> ps.MultiIndex.from_tuples(tuples, names=('number', 'color'))  
MultiIndex([(1,  'red'),
            (1, 'blue'),
            (2,  'red'),
            (2, 'blue')],
           names=['number', 'color'])