+ 1
Copy question in Python
Some notes on copy problems Case 1 a=b If a&b are int or str it doesnât matter If a&b are list, DataFrame or similar objects, they would refer to the same object all the time Any change in a would change b, vice versa Case 2 b=a.copy() This is a shallow copy a&b are different objects, but they share elements Adding elements to b wonât change a But any change in elements in a would change b, vice versa Case 3 Create a deep copy b=a.copy(deep=True) #as in Pandas a&b are different objects. They donât share elements. Any change on a wonât change b
1 Answer
+ 4
Basically, these are all the behavior of python programming language regarding different types of cases in copying list. I think you need an explanation about that.
There are some articles present on the internet which you can check them out. Here is one for you:)
https://www-geeksforgeeks-org.cdn.ampproject.org/v/s/www.geeksforgeeks.org/python-cloning-copying-list/amp/?amp_js_v=a2&_gsa=1&usqp=mq331AQCCAE%3D#referrer=https%3A%2F%2Fwww.google.com&_tf=From%20%251%24s&share=https%3A%2F%2Fwww.geeksforgeeks.org%2Fpython-cloning-copying-list%2F