I'm trying to update values of one data frame by performing calculations with a second data frame and update.
I simplified the code, since the problem seems to be a more general one.
At fist I make a copy a data frame by df_2 = df
, since the values of df have to remain untouched, only the values of df_2 should be updated.
Then I collect indexes for certain case:
indexes = df_2[(df_2['lat'] == float(lat)) & (df_2['lon'] == float(lon))].index.tolist()
for index in indexes:
if df_2.iloc[index]['value_age'] > 0:
df_2.at[index,'value'] = 1.123456
else:
continue
After df_2.at
is performed, both df AND df_2, value for that particular index is updated to 1.23456. I have no clue why this is.