1

I have a dataframe looks like

id     TakingTime   TestDesc      TestValue gender
1      28-02-2015   Bilirubin       0.20      2
1      28-02-2015   Cholesterol     169       2
1      28-02-2015   Sodium          129       2
1      28-02-2015   Potassium       3.38      2

1      29-02-2015   Bilirubin       0.20      2
1      29-02-2015   Cholesterol     169       2
1      29-02-2015   Sodium          129       2
1      29-02-2015   Potassium       3.38      2

2      29-02-2015   Bilirubin       0.20      1
2      29-02-2015   Cholesterol     169       1

2      31-02-2015   Sodium          129       1
2      31-02-2015   Potassium       3.38      1

and I want to create a new columns for each parameters checked the same day to have only one row for each id with the same taking time like

id     TakingTime   Bilirubin      Cholesterol    Sodium    Potassium   gender 
 1    28-02-2015      0.20             169          129         3.38      2
 1    29-02-2015      0.20             169          129         3.38      2
 2    29-02-2015      0.20             169          Nan         Nan       1
 2    31-02-2015      Nan              Nan          129         3.38      1

I tried with df.transpose but not really solve because he doesn't regroup all parameters in the same row

David
  • 23
  • 5

0 Answers0