Convert list of tuples to MultiIndex.
Each tuple is the index of one row/column.
Level of sortedness (must be lexicographically sorted by that level).
Names for the levels in the index.
See also
MultiIndex.from_arraysConvert list of arrays to MultiIndex.
MultiIndex.from_productMake a MultiIndex from cartesian product of iterables.
MultiIndex.from_frameMake a MultiIndex from a DataFrame.
Examples
>>> tuples = [(1, 'red'), (1, 'blue'),
... (2, 'red'), (2, 'blue')]
>>> pd.MultiIndex.from_tuples(tuples, names=('number', 'color'))
MultiIndex([(1, 'red'),
(1, 'blue'),
(2, 'red'),
(2, 'blue')],
names=['number', 'color'])
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.MultiIndex.from_tuples.html