I have a dataframe which looks like this
| index | School | id | Subjects |
|---|---|---|---|
| 0 | Sch1 | 123 | English maths social |
| 2 | Sch67 | 789 | English maths science |
| 3 | Sch12 | 123 | English Telugu Hindi |
But I want to convert it into below dataframe with each subject count and groupby id
| id | English | Telugu | maths | Hindi | science | social |
|---|---|---|---|---|---|---|
| 123 | 2 | 1 | 1 | 1 | 0 | 1 |
| 789 | 1 | 0 | 1 | 0 | 1 | 0 |
I tried with group by for each column and it didnt work for me
I want the code to be dynamic because the input is a large dataframe and I have taken only a chunk of df