title: Which Python Magic Method is Pandas Using?
body: <p>I have a class that contains a pandas DataFrame (self.my_df), and updating self.my_df does not work how I expect it to. Here's a simplified version of the code that illustrates my problem:</p>
  
  <pre><code>class my_obj(object):
      @property
      def my_df(self):
          if not hasattr(self, "_my_df"):
              self._my_df = pandas.DataFrame({ "A" : [1,2,3,],
                                               "B" : [4,5,6]}).fillna("")
          print("Retrieving!")
          return self._my_df
  
      @my_df.setter
      def my_df(self, my_new_df):
          print("Setting!")
          self._my_df = my_new_df.copy()
  </code></pre>
  
  <p>Here's what happens when I (try to) call these methods (from inside a separate instance method that I don't think matters here):</p>
  
  <pre><code>ipdb&gt; self.my_df
  Retrieving!
     A  B
  0  1  4
  1  2  5
  2  3  6
  ipdb&gt; self.my_df.loc[2, "B"] = "x"
  Retrieving!
  ipdb&gt; self.my_df
  Retrieving!
     A  B
  0  1  4
  1  2  5
  2  3  x
  ipdb&gt; self._my_df
     A  B
  0  1  4
  1  2  5
  2  3  x
  </code></pre>
  
  <p>I would expect <code>self.my_df.loc[2, "B"] = "x"</code> to call the setter, which it doesn't, or——if it <em>doesn't</em>——then I would expect self._my_df <strong>not to be set</strong>, which it is.</p>
  
  <p>What's happening here? My real situation is much more complex, but I believe this is the root confusion for me.</p>
  
  <p>Thanks for helping me clear this up.</p>