Asymmetry in corner case for DataFrame __getattr__
and __setattr__
#8994
Labels
Milestone
__getattr__
and __setattr__
#8994
A student of mine ran into a confusing problem which ended up being due to an asymmetry in
DataFrame.__setattr__
andDataFrame.__getattr__
when an attribute and a column have the same name. Here is a short example session:The confusion derived from the fact that in this situation,
data.__getattr__('y')
refers to the attribute, whiledata.__setattr__('y', val)
refers to the column.I understand that using attributes to access columns is not recommended, but the asymmetry in this corner case led to a lot of confusion! It would be better if
__getattr__
and__setattr__
would always refer to the same object.The text was updated successfully, but these errors were encountered: