Python | Pandas MultiIndex.from_product() Last Updated : 24 Dec, 2018 Comments Improve Suggest changes Like Article Like Report Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.from_product() function make a MultiIndex from the cartesian product of multiple iterables. Syntax: MultiIndex.from_product(iterables, sortorder=None, names=None) Parameters : iterables : Each iterable has unique labels for each level of the index. sortorder : Level of sortedness (must be lexicographically sorted by that level). names : Names for the levels in the index. Returns: index : MultiIndex Example #1: Use MultiIndex.from_product() function to construct a MultiIndex from the cartesian product of multiple iterables. Python3 # importing pandas as pd import pandas as pd # Create the first iterable Price =[20, 35, 60, 85] # Create the second iterable Name =['Vanilla', 'Strawberry'] # Print the first iterable print(Price) # Print the second iterable print("\n", Name) Output : Now let's create the MultiIndex using the above two iterables. Python3 # Creating the MultiIndex midx = pd.MultiIndex.from_product([Name, Price], names =['Name', 'Price']) # Print the MultiIndex print(midx) Output : As we can see in the output, the function has created a MultiIndex object using the cartesian product of these two iterables. Example #2: Use MultiIndex.from_product() function to construct a MultiIndex from the cartesian product of multiple iterables. Python3 # importing pandas as pd import pandas as pd # Create the first iterable Snake =['Viper', 'Cobra'] # Create the second iterable Variety =['Brown', 'Yellow', 'Black'] # Print the first iterable print(Snake) # Print the second iterable print("\n", Variety) Output : Now let's create the MultiIndex using the above two iterables. Python3 # Creating the MultiIndex midx = pd.MultiIndex.from_product([Snake, Variety], names =['Snake', 'Variety']) # Print the MultiIndex print(midx) Output : The function has created a MultiIndex using the two iterables. Comment More infoAdvertise with us Next Article Python | Pandas MultiIndex.from_product() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-multiIndex Practice Tags : python Similar Reads Python | Pandas MultiIndex.to_frame() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.to_frame() function create a DataFrame with the levels of the MultiI 2 min read Python | Pandas MultiIndex.from_tuples() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.from_tuples() function is used to convert list of tuples to MultiInd 2 min read Python | Pandas MultiIndex.from_arrays() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.from_arrays() function is used to convert arrays into MultiIndex. It 2 min read Python | Pandas dataframe.product() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.product() function return the value of the product for the requested 2 min read Python | Pandas MultiIndex.droplevel() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.droplevel() function return Index with requested level removed. If M 2 min read Python | Pandas MultiIndex.names Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.names attribute returns the names of levels in the MultiIndex. Synta 2 min read Python | Pandas dataframe.prod() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.prod() function return the value of the product for the requested axi 2 min read Python | Pandas MultiIndex.levshape Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.levshape attribute outputs a tuple containing the length of each lev 2 min read Python | Pandas Index.to_frame() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.to_frame() function create a dataFrame from the given index with a column 2 min read Python | Pandas MultiIndex.nlevels Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas MultiIndex.nlevels attribute returns the integer number of levels in the MultiI 2 min read Like