Python | Pandas Index.sort_values() Last Updated : 18 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 Index.sort_values() function is used to sort the index values. The function return a sorted copy of the index. Apart from sorting the numerical values, the function can also sort string type values. Syntax: Index.sort_values(return_indexer=False, ascending=True) Parameters : return_indexer : Should the indices that would sort the index be returned. ascending : Should the index values be sorted in an ascending order. Returns : Sorted copy of the index. sorted_index : pandas.Index indexer : numpy.ndarray, optional The indices that the index itself was sorted by. Example #1: Use Index.sort_values() function to sort the values present in the index. Python3 # importing pandas as pd import pandas as pd # Creating the index idx = pd.Index(['Beagle', 'Pug', 'Labrador', 'Sephard', 'Mastiff', 'Husky']) # Print the index idx Output : Now we will sort the index labels in the ascending order. Python3 1== # Sorting the index labels idx.sort_values(ascending = True) Output : As we can see in the output, the function has returned an index with its labels sorted. Example #2: Use Index.sort_values() function to sort the index labels in the descending order. Python3 # importing pandas as pd import pandas as pd # Creating the index idx = pd.Index([22, 14, 8, 56, 27, 21, 51, 23]) # Print the index idx Output : Now we will sort the index labels in non-increasing order. Python3 1== # sort the values in descending order idx.sort_values(ascending = False) Output : As we can see in the output, the function has returned a new index with its labels sorted in decreasing order. Comment More infoAdvertise with us Next Article Python | Pandas Index.sort_values() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-indexing Practice Tags : python Similar Reads Python | Pandas Index.values Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.values attribute return an array representing the data in the given Index object. Syntax: Index.values Parameter : None Returns : an a 2 min read Python | Pandas Index.get_values() 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.get_values() function returns the Index data as an numpy.ndarray. It retu 2 min read Python | Pandas Index.shape Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.shape attribute return a tuple of the shape of the underlying data in the given Index object. Syntax: Index.shape Parameter : None Ret 2 min read Python | Pandas Index.tolist() 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.tolist() function return a list of the values. These are each a scalar ty 1 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 Index.size Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.size attribute return the number of elements in the underlying data of the given Index object. Syntax: Index.size Parameter : None Ret 2 min read Python | Pandas Index.to_series() 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_series() function create a Series with both index and values equal to 2 min read Python | Pandas Series.sort_values() Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Pandas Series.sort_values() function is use 2 min read Python | Pandas Index.searchsorted() 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.searchsorted() function find indices where elements should be inserted to 2 min read Python | Pandas Index.where Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.where function return an Index of same shape as self and whose corresponding entries are from self where cond is True and otherwise ar 2 min read Like