【发布时间】:2018-02-28 07:34:03
【问题描述】:
#我正在使用下面的代码#
for i in test.construction:
if i.find("Wood"):
test["Category"]="tree"
print (test[["construction", "Category"]])
输出: 建筑类
Masonry tree
Masonry tree
Wood tree
Wood tree
我使用的是find 而不是'==',因为它可以在构造列中包含多个单词/字符串。
它每次都给"tree"。
当construction= "Masonry"时我想要Category="Mason"
感谢您的帮助!!
【问题讨论】:
标签: python python-3.x pandas dataframe