根据dfb值扩展数据框dfa

时间:2018-08-17 02:59:12

标签: python pandas dataframe join merge

我需要根据以下内容扩展数据框:

dfa = pd.DataFrame([['f150', 'wheel'],['f150', 'bed'],['escort', 'wheel'],['escort', 'rearseat']], columns=['model','system'])   
print(dfa)

model    system
0    f150     wheel
1    f150       bed
2  escort     wheel
3  escort  rearseat

dfb = pd.DataFrame([['one','f150',123],['two','escort',456],['three','escort',789],['four','f150',999]], columns = ['vehicle_number','model','mileage'])
print(dfb)

  vehicle_number   model  mileage
0            one    f150      123
1            two  escort      456
2          three  escort      789
3           four    f150      999

我需要生成一个包含所有车辆编号,系统和里程的组合列表。

vehicle_number    model    system    mileage
1                 f150     wheel     123
1                 f150     bed       123
2                 escort   wheel     456
2                 escort   rearseat  456
(etc)

0 个答案:

没有答案