
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Write a program in Python to sort all the elements in a given series in descending order
Input − Assume, you have a Series,
0 abdef 1 ijkl 2 Abdef 3 oUijl
Output − And the result for all the elements in descending order,
3 oUijl 1 ijkl 0 abdef 2 Abdef
Solution
To solve this, we will follow the steps given below −
Define a Series
Apply sort_values method with the argument as ascending = False. It is defined below,
data.sort_values(ascending=False)
Example
The complete code listing is as follows,
import pandas as pd l=["abdef","ijkl","Abdef","oUijl"] data=pd.Series(l) print("original series: \n ", data) print(data.sort_values(ascending=False))
Output
3 oUijl 1 ijkl 0 abdef 2 Abdef
- Related Articles
- Write a Python program to sort a given DataFrame by name column in descending order
- Write a Python program to shuffle all the elements in a given series
- Write a program in Python to round all the elements in a given series
- Python program to sort the elements of an array in descending order
- Write a program in Python to print the power of all the elements in a given series
- Golang Program To Sort The Elements Of An Array In Descending Order
- Swift Program to Sort the Elements of an Array in Descending Order
- C++ Program to Sort the Elements of an Array in Descending Order
- Write a program in Python to filter only integer elements in a given series
- Sort list elements in descending order in C#
- C# Program to order array elements in descending order
- C# program to sort an array in descending order
- 8085 Program to perform selection sort in descending order
- 8085 Program to perform bubble sort in descending order
- C program to sort an array in descending order

Advertisements