That’s not just a pandas thing: it’s a generic python thing. You always have to be conscious of the semantics of passing objects to functions in python. They are passed by reference, not by value, so it’s up to the code in the called function to copy any object before doing an “in place” operation on it. Here’s a thread which gives a classic example of that issue. But here we are dealing with predefined TF/Keras “Layer” functions and those are written to return independent objects and not to modify their arguments.
Residual Nets Question
          
            
              
              
                Course Q&A
              
            
            
          
          
            
              
              
                TensorFlow: Advanced Techniques Specialization
              
            
            
          
          
            
              
              
                Custom Models, Layers and Loss Functions with TF