0

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:

enter image description here

Tried:

df = pd.DataFrame(data, columns = ['Name','Age','Gender','Subject','minmark','maxmark'])

enter image description here

Mis match

  1. Colunm Names Subject_MinMark is not achived.
  2. LIST, the new Derived colunm is not achived.
Timus
  • 7,225
  • 5
  • 10
  • 24
user2458922
  • 1,456
  • 1
  • 15
  • 27

0 Answers0