pandas dataframe, copy by value


Question

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

1
15
11/16/2012 3:43:15 PM

Accepted Answer

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().

36
11/16/2012 3:55:06 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon