I have a originalFrame with:
name val
n1 5
n2 999
n3 3
So, I created a subFrame: ( intention to reference row 'n2' )
subFrame = originalFrame.loc[ originalFrame['val'] == 999 ]
After that, I merged the subFrame with another DataFrame to get the column of this frame:
mergeFrame:
onColumn newName
999 n50
subFrame = subFrame.merge( mergeFrame, left_on='val', right_on='onColumn', how='left' )
subFrame['name'] = subFrame['newName']
After that, because loc generates a reference, I expected the updated of row with name 'n2' in the original DataFrame to 'n50', because my reference variable was updated, but my originalFrame still has the old content.
My expected result for the originalFrame content:
name val
n1 5
n50 999
n3 3
What did I get wrong about .loc[] behavior? How Can I fix this?
Best Regards, Luis