Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

building class that inherits pandas DataFrame

I am trying to write a class that inherits pandas' DataFrame class for some custom data that I am working on.

class EquityDataFrame(DataFrame):
    def __init__(self, *args, **kwargs):
        DataFrame.__init__(self, *args, **kwargs)

    def myfunc1(self,...)
        ... # does something

    def myfunc2(self, ...)
        ... # does something

In PyCharm, I get the following warning for the name of the class EquityDataFrame:

Class EquityDataFrame must implement all abstract methods 

This inspection detects when there aren't all abstract properties/methods defined in the subclass

I tried googling, but I couldn't find a useful description of this warning. Can someone help me what this warning means?

like image 676
uday Avatar asked Nov 01 '22 07:11

uday


1 Answers

After looking for 6 years, pylint gave me the answer :
[W0223(abstract-method), CustomDataFrame] Method '_constructor_expanddim' is abstract in class 'DataFrame' but is not overridden

And indeed implementing

@property
def _constructor_expanddim(self) -> Type["CustomDataFrame"]:
    raise NotImplementedError("Not supported for CustomDataFrames!")

made the warning disappear.

like image 62
GuiGav Avatar answered Nov 08 '22 04:11

GuiGav