熊猫搜索第二个数据帧并移动到第一个数据帧

时间:2020-12-23 10:19:43

标签: python pandas dataframe search

我试图能够使用我的第一个 DF 中的数据来搜索我的第二个 DF 并将结果移回我的第一个 dataFrame。我在下面添加了我的数据框。

DF

Name                   Company       Console        Search
Phill Spencer          Microsoft      Xbox One      Phill Spencer Microsoft
Larry Hryb             Microsoft      Xbox One      Larry Hryb Microsoft
Bill Gates             Microsoft      Xbox 360      Bill Gates Microsoft
Kenichiro Yoshida      Sony           PS4           Kenichiro Yoshida Sony
Howard Stringer        Sony           PS5           Howard Stringer PS5

DF1

Age Results
4   Phil Spencer, Microsoft
3   Larry Hryb, Microsoft
7   Bill Gates, Microsoft, US
5   Kenichiro, Yoshida, Sony
1   Howard Stringer, Sony, PS5

预期 DF

Name                   Company       Console                 Company Matched         Console Matched           Age
Phill Spencer          Microsoft      Xbox One                       Matched                                    4
Larry Hryb             Microsoft      Xbox One                       Matched                                    3
Bill Gates             Microsoft      Xbox 360                       Matched                                    7
Kenichiro Yoshida      Sony           PS4                            Matched                                    5
Howard Stringer        Sony           PS5                                                  Matched              1

我希望能够获取 DF['Search'] 中的数据并使用它来搜索而不是 DF1['Results'] 如果有匹配则它会创建列并将匹配的放入单元格中,但是我还需要它来消除比赛中的年龄。

0 个答案:

没有答案