【发布时间】:2019-09-10 15:40:39
【问题描述】:
我有两个不同的数据框,即,
firstDF = pd.DataFrame([{'mac':1,'location':['kitchen']}])
predictedDF = pd.DataFrame([{'mac':1,'location':['lab']}])
如果 predictDF 的 mac 列值包含在 firstDF 的 mac 列值中,则 firstDF 的 location 列值应该扩展 predictDF 的 location 列,并且 firstDF 的结果应该是,
firstDF
mac location
0 1 ['kitchen','lab']
我试过了,
firstDF.loc[firstDF['mac'] == predictedDF['mac'], 'mac'] = firstDF.loc[firstDF['location'].extend(predictedDF['location']), 'location']
虽然返回相同,
AttributeError: 'Series' object has no attribute 'extend'
【问题讨论】:
-
我添加了更多值的测试,输出是你需要的吗?
标签: python-3.x pandas