0

If df1 looks like:

Build_ID, Request_ID, Group_ID, Average
185, 100, G1, 200
186, 100, G1, 201
185, 102, G1, 203
186, 102, G1, 205
185, 200, G3, 200
186, 200, G3, 201
185, 202, G3, 203
186, 202, G3, 205

and df2 looks like:

Build_ID, Group_ID, Group_Average
185, G1, 300
186, G1, 301
185, G3, 401
186, G3, 402

and final result should look like:

 Build_ID, Request_ID, Group_ID, Average, Group_Average
    185, 100, G1, 200, 300
    186, 100, G1, 201, 301
    185, 102, G1, 203, 300
    186, 102, G1, 205, 301
    185, 200, G3, 200, 401
    186, 200, G3, 201, 402
    185, 202, G3, 203, 401
    186, 202, G3, 205, 402

Which basically has all rows from df1 and Group_Average from df2 is repeated for each Group_ID and Build_ID. I tried merge and join using different joint but can't get the result I am looking for. Thanks

1 Answer 1

0

Is that what you want?

In [60]: df1.merge(df2, on=['Build_ID','Group_ID'])
Out[60]:
   Build_ID  Request_ID Group_ID  Average  Group_Average
0       185         100       G1      200            300
1       185         102       G1      203            300
2       186         100       G1      201            301
3       186         102       G1      205            301
4       185         200       G3      200            401
5       185         202       G3      203            401
6       186         200       G3      201            402
7       186         202       G3      205            402
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.