0
我想根據其add_suburb值填寫縣列缺失值。我嘗試了以下兩個不起作用的代碼只有當它不是空或空時才填寫列
for index, row in fileco.iterrows():
df.loc[df['add_suburb'].str.contains(str(row['place'])) & (df['county'].str=='') , 'county'] = str('County '+row['county']).title()
for index, row in fileco.iterrows():
df.loc[df['add_suburb'].str.contains(str(row['place'])) & (df['county'].str is None) , 'county'] = str('County '+row['county']).title()
但是,如果我不檢查None或=='',以下代碼有效。
for index, row in fileco.iterrows():
df.loc[df['add_suburb'].str.contains(str(row['place'])) , 'county'] = str('County '+row['county']).title()
什麼是隻填寫缺失列值的正確方法?我應該如何糾正&之後的狀況?