You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an AttributeError is raised inside a property in DataFrame, regular attribute access fails and __getattr__ in NDFrame is called.
Since the property's attribute name is neither in _internal_names_set nor _info_axis, a new exception is risen and the original stack trace is lost.
importpandasaspdclassA(pd.DataFrame):
@propertydeffoo(self):
return1/0@propertydefbar(self):
returnself.i_dont_exist>>>a=A()
>>>a.fooZeroDivisionError>>>a.bar---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)
<ipython-input-35-0eea75f4bdee>in<module>()
12#a.foo # ZeroDivisionError13--->14a.bar# AttributeError: 'A' object has no attribute 'bar'1516#a.i_dont_exist # AttributeError: 'str' object has no attribute 'isnull'/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pycin__getattr__(self, name)
2148returnself[name]
2149raiseAttributeError("'%s' object has no attribute '%s'"%->2150 (type(self).__name__, name))
21512152def__setattr__(self, name, value):
AttributeError: 'A'objecthasnoattribute'bar'>>>a.i_dont_exist# a.bar should include this in the stack trace:AttributeError: 'A'objecthasnoattribute'i_dont_exist'
I am not entirely sure why this happens. The exception (on the inner property) is somehow not propogating up the stack. care to have a look and investigate?
When an
AttributeError
is raised inside a property in DataFrame, regular attribute access fails and__getattr__
inNDFrame
is called.Since the property's attribute name is neither in
_internal_names_set
nor_info_axis
, a new exception is risen and the original stack trace is lost.The text was updated successfully, but these errors were encountered: