[Solved] Write a Python program to sort the following data in ascending order of age :

   RSS

1
Topic starter

Write a Python program to sort the following data in ascending order of age :

 

 

This topic was modified 1 year ago by CodeWithBishal-admin
1 Answer
1
Topic starter

Code:

import pandas as pd


data = {
'Name':["Seema", "Nikshav", "Rajni"],
'Age':[36,40,39],
'Designation':["Manager", "Clerk", "Accountant"]
}
df = pd.DataFrame(data)


df.sort_values(by="Age", ascending=True)


print(df)

 

Output:

      Name  Age Designation
0    Seema   36     Manager
1  Nikshav   40       Clerk
2    Rajni   39  Accountant