title: When creating a wrapper class in python, how do I get the superclass's methods to return an instance of my wrapper class
body: <p>For example if I create a simple wrapper around a pandas dataframe:</p>
  
  <pre><code>    from pandas import DataFrame
  
      class MyDataFrame(DataFrame):
  
          def __init__(self,data):
  
              DataFrame.__init__(self,data)
  
          @staticmethod
          def add(a, b):
              return a + b
  </code></pre>
  
  <p>and then I instantiate it..</p>
  
  <pre><code>    x = MyDataFrame([1,2,3])
  
              x.add(1,2)
              #    =&gt; 3
  
              type(x)
              #    =&gt; __main__.MyDataFrame
  </code></pre>
  
  <p>it works. But, if I call a a dataframe method on it that returns a dataframe, It is no loger an instance of my wrapper class.</p>
  
  <pre><code>    y = x.reindex([3,4,5])
      type(y)
      #    =&gt; pandas.core.frame.DataFrame
  </code></pre>
  
  <p>How do I get it to return an instance of MyDataFrame for all DataFrame methods? Is this a common issue? Am I approaching this in the wrong way?</p>