final_merge['user_ID']=''
for i in range(len(final_merge)):
if final_merge.loc[i,'user_x']=='nan':
final_merge['user_ID'][i]= final_merge['user_y'][i]
else:
final_merge['user_ID'][i]= final_merge['user_x'][i]
When I use code,there are two warnings in my console.
__main__:6: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
__main__:4: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
I know the warning mean,but how to change my code to avoid these warning?