请帮我解决这个问题。我在网上搜索,但找不到解决方案。dfId Fruit1 Apple1 Carrot2 Apple3 Carrotlist = [fruit, vegetable, both]问题是,如何为每个 id 分配,如果 id 的水果列包含苹果或胡萝卜列表。如果 id 包含苹果,则分配 ID 1 水果,如果只有胡萝卜,则是蔬菜,如果两者都是,则两者都是。我尝试按行使用 str.contains,但它不带 ID 列。结果NewdfId Fruit New_col1 Apple Both1 Carrot Both2 Apple Fruit3 Carrot Vegetable 非常感谢。
添加回答
举报
0/150
提交
取消
