I have a dataframe:
ID   Value    Name    Score  Card_type  Card_number
1      NA     John     242      X           23
1     124     John      NA      X           23
1     124     John     242      Y           25
1     124     NA       242      Y           NA
2      55     Mike      NA      X           11
2      55     NA       431      X           11
2      55     Mike     431      Y           14
2      NA     Mike     431      Y           14
As you see, there are IDs and each of them has two groups (Card_type) for column Card_number. Also as you see, some rows with same ID and Card_type have same missing values in some columns. What I want to get is, to make each ID be one row with filled columns. And column Card_number must be split into two columns Card_number_type_X and Card_number_type_X and column Card_type must be removed.
So the desired result must look like this:
ID   Value    Name    Score   Card_number_type_X  Card_number_type_Y
1     124     John     242             23                   25
2      55     Mike     431             11                   14                 
How could I do that?