Hard
Rank Within Each Department
Add a column
rank: each student's rank by cgpa inside their department, highest first, with ties sharing the lowest rank (groupby('dept')['cgpa'].rank(method='min', ascending=False)). Print the rows sorted by dept, then rank, then name, as dept rank name.Input
Lines 'name dept cgpa credits', then END.
Output
Lines.
Sample 1
Input
Mim CSE 3.82 120 Rafi EEE 3.41 98 Sara CSE 3.95 132 Tuhin BBA 3.60 110 Nadia CSE 3.71 125 END
Output
BBA 1 Tuhin CSE 1 Sara CSE 2 Mim CSE 3 Nadia EEE 1 Rafi
Sample 2
Input
A CSE 3.00 100 END
Output
CSE 1 A
Output appears here