我正在尝试设置数据框“df”中名为“barony2”的列的值,如果“add_urban”列包含ref_文件的当前iterrows“Townland”值,请使用以下代码。在
df = pd.read_csv('a.csv')
ref_file = pd.read_csv('b.csv')
for index, row in ref_file.iterrows():
cond = str(row['Townland']) in df.add_suburb
df.loc[cond, 'barony2'] = str(row['Barony'])
我得到KeyError: 'cannot use a single bool to index into setitem'
任何帮助都非常感谢。在
目前没有回答
相关问题 更多 >
编程相关推荐