Take the 2-minute tour ×

I noticed a bug in my program and the reason it is happening is because it seems that pandas is copying by reference a pandas dataframe instead of by value. I know immutable objects will always be passed by reference but pandas dataframe is not immutable so I do not see why it is passing by reference. Can anyone provide some information?

Thanks! Andrew

share|improve this question

1 Answer 1

up vote 11 down vote accepted

All functions in Python are "pass by reference", there is no "pass by value". If you want to make an explicit copy of a pandas object, try new_frame = frame.copy().

share|improve this answer
Note that this does not include the frame.index as of version 0.12. However, a fix seems to be on the way for 0.13 (as mentioned in this related question: GitHub Pandas Issue 4202) –  ojdo Nov 26 '13 at 14:46

Your Answer


