I want to define a class which does not inherit from pandas.DataFrame but sometimes acts like it. For example, I can do:
import pandas
import numpy
class FalseDF(object):
def __init__(self, df):
self.df = df
def __getitem__(self, item):
return self.df.__getitem__(item)
df = pandas.DataFrame(numpy.reshape(numpy.arange(10), (2, 5)))
print(df)
which gives:
0 1 2 3 4
0 0 1 2 3 4
1 5 6 7 8 9
and now:
fdf = FalseDF(df)
print(fdf[3])
gives:
0 3
1 8
Name: 3, dtype: int64
How can I now make the following syntax also work?
print(fdf.iloc[1])
or
print(fdf.loc[2])