Modify a dictionary under a new name modifies the original dictionary

copy is a shallow copy, i.e. it’s not copied recursively. That’s what deepcopy is for, as I’ve mentioned above. Your x is a Dict, so regular copy creates a distinct Dict instance, but the DataFrame inside is still the same object.

I don’t know what row is, so I can only guess at what’s going wrong. If it still doesn’t work, please provide a MWE to make it easier to debug your problem.

2 Likes