pyspark.pandas.MultiIndex.from_tuples

static MultiIndex.from_tuples(tuples: List[Tuple], sortorder: Optional[int] = None, names: Optional[List[Union[Any, Tuple[Any, …]]]] = None) → pyspark.pandas.indexes.multi.MultiIndex[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'])