classmethod MultiIndex.from_product(iterables, sortorder=None, names=None)
[source]
Make a MultiIndex from the cartesian product of multiple iterables.
Parameters: |
|
---|---|
Returns: |
|
See also
MultiIndex.from_arrays
MultiIndex.from_tuples
MultiIndex.from_frame
>>> numbers = [0, 1, 2] >>> colors = ['green', 'purple'] >>> pd.MultiIndex.from_product([numbers, colors], ... names=['number', 'color']) MultiIndex([(0, 'green'), (0, 'purple'), (1, 'green'), (1, 'purple'), (2, 'green'), (2, 'purple')], names=['number', 'color'])
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.MultiIndex.from_product.html