How to merge two columns in pandas dataframe into a list

Viewed 12949

I am trying to merge two dataframes into a new dataframe, where two columns will be merged as a list. For example: here is df1

   tkt_ticket_opened  tkt_adjtimetorepair  result_data_cohort_id
0      2017-01-09 05             0.075883                      1
1      2017-01-09 06             0.286550                      1
2      2017-01-09 07             0.124234                      1
3      2017-01-09 08             0.144504                      1
4      2017-01-09 09             0.416698                      1
5      2017-01-09 10             0.103199                      1
6      2017-01-09 11             0.063608                      1
7      2017-01-09 12             0.378695                      1
8      2017-01-09 13             0.686515                      1
9      2017-01-09 14             0.671016                      1
10     2017-01-09 15             0.406588                      1
11     2017-01-09 16             0.957627                      1
12     2017-01-09 17             0.504509                      1
13     2017-01-09 18             0.416487                      1
14     2017-01-09 19             0.412306                      1
15     2017-01-09 20             0.929061                      1
16     2017-01-09 21             0.421006                      1
17     2017-01-09 22             0.365754                      1
18     2017-01-09 23             0.557050                      1

df2

   tkt_ticket_opened  tkt_adjtimetorepair  result_data_cohort_id
0      2017-01-09 05             0.065538                      0
1      2017-01-09 06             0.379438                      0
2      2017-01-09 07             0.190816                      0
3      2017-01-09 08             0.594454                      0
4      2017-01-09 09             0.649041                      0
5      2017-01-09 10             0.509891                      0
6      2017-01-09 11             0.260283                      0
7      2017-01-09 12             0.340179                      0
8      2017-01-09 13             0.402101                      0
9      2017-01-09 14             0.497638                      0
10     2017-01-09 15             0.373385                      0
11     2017-01-09 16             0.533326                      0
12     2017-01-09 17             0.366825                      0
13     2017-01-09 18             0.892164                      0
14     2017-01-09 19             0.723326                      0
15     2017-01-09 20             1.088171                      0
16     2017-01-09 21             0.408264                      0
17     2017-01-09 22             0.507147                      0
18     2017-01-09 23             0.486486                      0

the resulting dataframe would be

   tkt_ticket_opened  tkt_adjtimetorepair  
0      2017-01-09 05             [0.075883, 0.065538 ]                 
1      2017-01-09 06             [0.286550, 0.379438 ]                 
2      2017-01-09 07             [0.124234, 0.190816 ]                   
....

Any help with this would be greatly appreciated.

2 Answers
Related