In this python pandas program, we will sort a given Series using Pandas library.
Steps to solve the program
- Import pandas library as pd.
- Create a series using pd.Series().
- Now sort the given series using pd.Series(series_name).sort_values().
- 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