我有两个不同的 csv,我在两个数据帧中读取。我想将列 df1['building_type] 与 df2['model'] 匹配,并将相应的行附加到 df1。
数据框 1:
data = [{'length': '34', 'width': '58.5', 'height': '60.2', 'building_type': ['concrete','wood','steel','laminate']},
{'length': '42', 'width': '33', 'height': '23', 'building_type': ['concrete_double','wood_double','steel_double']}]
df1 = pd.DataFrame(data)
print(df1)
数据框 2:
data2 = [{'type': 'A1', 'floor': '2', 'model': ['wood','laminate','concrete','steel']},
{'type': 'B3', 'floor': '4', 'model': ['wood_double','concrete_double','steel_double']}]
df2=pd.DataFrame(data2)
print(df2)
最终数据框:
length width height building_type type floor
0 34 58.5 60.2 [concrete, wood, steel, laminate] A1 2
1 42 33 23 [concrete_double, wood_double, steel_double] B3 4
交互式爱情
相关分类