I have two dataframes old and new. I wanted to compare the new dataframe with old dataframe and when their is name and category match i want to append the specific value from new dataframe to old dataframe, while my code is printing the results after if condition its not appending values. Here is my code
for old in df_old.iterrows():
for new in df_new.iterrows():
if (old[1]['Name'] == new[1]['Name']) & (old[1]['Category'] == new[1]['Category']):
print(old)
#Code below not working
old[1]['New Category'] = new[1]['Category']
old[1]['New Sub Category'] = new[1]['Sub-Category']
old[1]['New Name'] = new[1]['Name']
columns
df_old = ['Name', 'JobNo', 'Category', 'Sub Category', 'New Category', 'New Sub Category', 'New Name']
df_new = ['Name', 'JobNo', 'Category', 'Sub-Category']