I have a dataframe like this
| Student ID | Subject | Current class | assessment class | prev cls | current cls | next cls |
|---|---|---|---|---|---|---|
| 101 | English | Class 2 | Class 2 | -- | Class2 Pass | -- |
| 101 | English | Class2 | Class3 | -- | -- | Class3 Pass |
| 101 | Mathematics | Class 2 | Class 2 | -- | Class 2 fail | -- |
| 101 | Mathematics | Class 2 | Class 1 | Class 1 fail | -- | -- |
| 102 | English | Class 2 | Class 2 | -- | Class2 Pass | -- |
| 102 | English | Class 2 | Class 3 | -- | -- | Class 3 Fail |
| 102 | Mathematics | Class2 | Class2 | -- | Class2 fail | -- |
| 102 | Mathematics | Class2 | Class1 | Class1 Pass | -- | -- |
I want a output like this
| Student ID | Subject | Current class | Expert lvl |
|---|---|---|---|
| 101 | English | Class2 | class3 pass |
| 101 | Mathematics | Class 2 | class 1 fail |
| 102 | English | Class2 | class2 pass |
| 102 | Mathematics | Class 2 | class 1 pass |
The condition are a student who belongs to class-2 takes a quiz of class-2
- If gets pass he/she goes one level up and tries class-3 quiz.
- If he/she passes the class-3 quiz his/her expertise level is fixed as class-3 in that subject.
- If he/she fails class-3 quiz his/her expert level is fixed as class-2 (only If he/she has passed class-2 quiz) otherwise his/her expert level is fixed as class-1 either he passes or fails class-1.
How do I write in python to get this kind of data frame?