import pandas as pd
class NewDF( pd.DataFrame ):
    def __init__( self , data ):
        super().__init__( data )
a = NewDF( [1,2,3,4])
a.__class__

>>> __main__.NewDF

a.iloc[2:4].__class__

>>> pandas.core.frame.DataFrame

Problem description

Is there a method for inheritance when coding with new DataFrame class and select the DataFrame with loc / iloc / other function in itself class instead of the child class?

Comment From: chris-b1

See docs here - need to define, e.g.. _constructor.

Though sub-classing is generally recommended to be avoided, look to composition/free functions first if you can.

Comment From: cyrushu

Thanks a lot~ Cheers