The input DataFrame is
import pandas as pd
data = [['Adam',12,'M','A',12,15],
['Adam',12,'M','B',13,15],
['Adam',12,'M','C',14,14],
['Mini',12,'F','A',10,14],
['Mini',12,'F','D',14,15],
['Mini',12,'F','C',13,16],
]
df = pd.DataFrame(data, columns = ['Name','Age','Gender','Subject','minmark','maxmark'])
df
Name Age Gender Subject minmark maxmark
Adam 12 M A 12 15
Adam 12 M B 13 15
Adam 12 M C 14 14
Mini 13 F A 10 14
Mini 13 F D 14 15
Mini 13 F C 13 16
The output is such that
grouped by Name Age Gender
'minmark' and 'max mark' are prefixed by 'subject'
'LIST' , is a new column, Sorted combination of subjects the Student appeared.
Expected:
Tried:
df = pd.DataFrame(data, columns = ['Name','Age','Gender','Subject','minmark','maxmark'])
Mis match
- Colunm Names Subject_MinMark is not achived.
- LIST, the new Derived colunm is not achived.