pandas.MultiIndex.to_list#
- MultiIndex.to_list()[source]#
Return a list of the elements of the MultiIndex.
The list will be a list of tuples, with the length of each tuple corresponding to the number of levels in the MultiIndex.
- Returns:
- list
A list of tuples representing the MultiIndex elements.
See also
Index.to_listReturn a list of the values for an Index.
Examples
>>> mi = pd.MultiIndex.from_product([["a", "b"], ["apple", "banana"]]) >>> mi.to_list() [('a', 'apple'), ('a', 'banana'), ('b', 'apple'), ('b', 'banana')]