For example if I create a simple wrapper around a pandas dataframe:
from pandas import DataFrame
class MyDataFrame(DataFrame):
def __init__(self,data):
DataFrame.__init__(self,data)
@staticmethod
def add(a, b):
return a + b
and then I instantiate it..
x = MyDataFrame([1,2,3])
x.add(1,2)
# => 3
type(x)
# => __main__.MyDataFrame
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.
y = x.reindex([3,4,5])
type(y)
# => pandas.core.frame.DataFrame
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?