Python | Pandas MultiIndex.levshape 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.levshape attribute outputs a tuple containing the length of each level in the MultiIndex. Syntax: MultiIndex.levshape Example #1: Use MultiIndex.levshape attribute to find the length of each levels in the MultiIndex. Python3 # importing pandas as pd import pandas as pd # Creating the array array =[[1, 2, 3], ['Sharon', 'Nick', 'Bailey']] # Print the array print(array) Output : Now let's create the MultiIndex using this array Python3 # Creating the MultiIndex midx = pd.MultiIndex.from_arrays(array, names =('Number', 'Names')) # Print the MultiIndex print(midx) Output : Now we will find the length of each levels in the MultiIndex. Python3 1== # Print the length of each level in MultiIndex midx.levshape Output : As we can see in the output, the length of each levels in the midx MultiIndex is (3, 3). Example #2: Use MultiIndex.levshape attribute to find the length of each levels in the given MultiIndex. Python3 # importing pandas as pd import pandas as pd # Creating the array array = [[1, 2, 3], ['Sharon', 'Nick', 'Bailey'], ['Doctor', 'Scientist', 'Physicist']] # Print the array print(array) Output : Now let's create the MultiIndex using this array Python3 # Creating the MultiIndex midx = pd.MultiIndex.from_arrays(array, names = ('Ranking', 'Names', 'Profession')) # Print the MultiIndex print(midx) Output : Now we will find the length of each levels in the MultiIndex. Python3 1== # Print the length of each levels in MultiIndex midx.levshape Output : As we can see in the output, the length of each level in the midx is 3. 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.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.is_lexsorted() 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.is_lexsorted() function return True if the labels are lexicographica 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.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.reorder_levels() 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 or 2 min read Pandas Index.append() - Python Index.append() method in Pandas is used to concatenate or append one Index object with another Index or a list/tuple of Index objects, returning a new Index object. It does not modify the original Index. Example:Pythonimport pandas as pd idx1 = pd.Index([1, 2, 3]) idx2 = pd.Index([4, 5]) res = idx1. 2 min read Like