Python | Pandas Series.sort_index() Last Updated : 05 Feb, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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_index() function is used to sort the index labels of the given series object. Syntax: Series.sort_index(axis=0, level=None, ascending=True, inplace=False, kind='quicksort', na_position='last', sort_remaining=True) Parameter : axis : Axis to direct sorting. This can only be 0 for Series. level : If not None, sort on values in specified index level(s). ascending : Sort ascending vs. descending. inplace : If True, perform operation in-place. kind : Choice of sorting algorithm. na_position : Argument ‘first’ puts NaNs at the beginning, ‘last’ puts NaNs at the end. sort_remaining : If true and sorting by level and index is multilevel, sort by other levels too (in order) after sorting by specified level. Returns : Series Example #1: Use Series.sort_index() function to sort the index labels of the given series object. Python3 # importing pandas as pd import pandas as pd # Creating the Series sr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio', 'Moscow']) # Create the Index index_ = ['City 5', 'City 6', 'City 4', 'City 2', 'City 3', 'City 1'] # set the index sr.index = index_ # Print the series print(sr) Output : Now we will use Series.sort_index() function to sort the index labels of the given series object. Python3 1== # sort the index labels sr.sort_index() Output : As we can see in the output, the Series.sort_index() function has successfully sorted the index labels of the given series object. Example #2: Use Series.sort_index() function to sort the index labels of the given series object. Python3 # importing pandas as pd import pandas as pd # Creating the Series sr = pd.Series([19.5, 16.8, 22.78, 20.124, 18.1002]) # Create the Index index_ = [5, 3, 2, 1, 4] # set the index sr.index = index_ # Print the series print(sr) Output : Now we will use Series.sort_index() function to sort the index labels of the given series object. Python3 1== # sort the index labels sr.sort_index() Output : As we can see in the output, the Series.sort_index() function has successfully sorted the index labels of the given series object. Comment More infoAdvertise with us Next Article Python | Pandas Series.ix S Shubham__Ranjan Follow Improve Article Tags : Pandas Python-pandas Python pandas-series-methods AI-ML-DS With Python Similar Reads 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 Sort a Pandas Series in Python Series is a one-dimensional labeled array capable of holding data of the type integer, string, float, python objects, etc. The axis labels are collectively called index. Now, Let's see a program to sort a Pandas Series. For sorting a pandas series the Series.sort_values() method is used. Syntax: Se 3 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 Series.ix 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 series is a One-dimensional ndarray with axis labels. The labels need not be un 2 min read Python | Pandas Series.min() 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.min() function return the mod 3 min read Python | Pandas Series.reset_index() 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.reset_index() function genera 2 min read Like