Python | Pandas MultiIndex.reorder_levels() Last Updated : 24 Dec, 2018 Summarize Comments Improve Suggest changes Share 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.reorder_levels() function is used to rearrange levels using input order. It may not drop or duplicate levels. The function take list as an input which contains the desired order of the levels of the MultiIndex. Syntax: MultiIndex.reorder_levels(order) Parameters : order : list containing the order of levels Returns : A new MultiIndex Example #1: Use MultiIndex.reorder_levels() function to reorder the levels of the MultiIndex. Python3 # importing pandas as pd import pandas as pd # Create the MultiIndex midx = pd.MultiIndex.from_arrays([['Networking', 'Cryptography', 'Anthropology', 'Science'], [88, 84, 98, 95]]) # Print the MultiIndex print(midx) Output : Now let's reorder the level of the MultiIndex. Python3 # reorder the levels such that # 1st level appears before the 0th midx.reorder_levels([1, 0]) Output : As we can see in the output, the function has returned a new MultiIndex having the levels set in the passed order. Example #2: Use MultiIndex.reorder_levels() function to reorder the levels of the MultiIndex. Python3 # importing pandas as pd import pandas as pd # Create the MultiIndex midx = pd.MultiIndex.from_arrays([['Beagle', 'Sephard', 'Labrador', 'Retriever'], [8, 4, 11, 3], ['A1', 'B1', 'A2', 'C1']]) # Print the MultiIndex print(midx) Output : Now let's reorder the levels of the MultiIndex. Python3 # reorder the levels midx.reorder_levels([0, 2, 1]) Output : As we can see in the output, the function has returned a new MultiIndex having the levels set in the passed order. Comment More infoAdvertise with us Next Article Python | Pandas MultiIndex.droplevel() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-multiIndex Practice Tags : python Similar Reads Python | Pandas MultiIndex.set_labels() 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.set_labels() function set new labels on MultiIndex. Defaults to retur 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.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 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.sortlevel() 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.sortlevel() function sort MultiIndex at the requested level. The res 2 min read Python | Pandas MultiIndex.swaplevel() 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.swaplevel() function is used to swap levels of the MultiIndex. It sw 2 min read Like