# df is the dataframe
# x and prop_area are columns
# iterate over the column
for index, row in df.iterrows():
if ( df.at[index,'prop_area'] =='Urban'):
df.at[index,'x'] = '3'
elif ( df.at[index,'prop_area'] =='Semiurban'):
df.at[index,'x'] = '4'
elif ( df.at[index,'prop_area'] =='Someothertype'):
df.at[index,'x'] = '5'
else:
continue
最简单的方法是
相关问题 更多 >
编程相关推荐