Subclassing pandas classes seems a common need but I could not find references on the subject. (It seems that pandas developers are still working on it: https://github.com/p
There is now an official guide on how to subclass Pandas data structures, which includes DataFrame as well as Series.
The guide is available here: https://pandas.pydata.org/pandas-docs/stable/development/extending.html#extending-subclassing-pandas
The guide mentions this subclassed DataFrame from the Geopandas project as a good example: https://github.com/geopandas/geopandas/blob/master/geopandas/geodataframe.py
As in HYRY's answer, it seems there are two things you're trying to accomplish:
_constructor property which should return your type._metadata attribute.Here's an example:
class SubclassedDataFrame(DataFrame):
_metadata = ['added_property']
added_property = 1 # This will be passed to copies
@property
def _constructor(self):
return SubclassedDataFrame