我想向 DataFrame 的子类添加属性,但出现错误:
>>> import pandas as pd
>>>class Foo(pd.DataFrame):
... def __init__(self):
... self.bar=None
...
>>> Foo()
RuntimeError: maximum recursion depth exceeded
你想这样写:
class Foo(pd.DataFrame):
def __init__(self):
super(Foo, self).__init__()
self.bar = None
See the 蟒蛇的__init__ syntax https://stackoverflow.com/questions/6013844/python-init-syntax问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)