Program to sort a given Series using Pandas

In this python pandas program, we will sort a given Series using Pandas library.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create a series using pd.Series().
  3. Now sort the given series using pd.Series(series_name).sort_values().
  4. Print the output.
				
					import pandas as pd
df = pd.Series([55,23,10,87])
print("Original Data Series:")
print(df)
new = pd.Series(df).sort_values()
print(new)
				
			

Output :

				
					Original Data Series:
0    55
1    23
2    10
3    87
dtype: int64
2    10
1    23
0    55
3    87
dtype: int64
				
			

convert a series of lists into one series

add some data to an existing series

Leave a Comment