合并两个数据框与包含字典的列

时间:2020-06-12 11:06:53

标签: python pandas dictionary zip

我有2个数据框问题,答案:

问题:

productId        question        questionId    total_answers
---------        --------        ----------    -------------
147374           I wear Tan       4475521            2
                 Sand w/ Yellow
                 undertone ..

答案:

productId       questionId     answerId      answer
---------       ----------     --------      ------
147374           4475521        123456       answer1
147374           4475521        654321       answer2

我想要这样的结果:

productId     questionId      answers
---------     ----------      -------
147374         4475521        [{'answerId':'123456','answer':'answer1'},
                               {'answerId' :'654321','answer':'answer2'}]

0 个答案:

没有答案