Skip to content
Snippets Groups Projects
Commit 3df9c5dd authored by ksonj's avatar ksonj Committed by Reynold Xin
Browse files

Better error message on access to non-existing attribute

I believe column access via `__getattr__` is bad and shouldn't be implicitly encouraged by the error message when accessing a non-existing attribute on DataFrame. This patch changes the error message from 'no such column'  to the more generic 'no such attribute', which is also what Pandas DFs will throw.

Author: ksonj <kson@siberie.de>

Closes #5771 from ksonj/master and squashes the following commits:

bcc2220 [ksonj] Better error message on access to non-existing attribute
parent 687273d9
No related branches found
No related tags found
No related merge requests found
......@@ -633,7 +633,8 @@ class DataFrame(object):
[Row(age=2), Row(age=5)]
"""
if name not in self.columns:
raise AttributeError("No such column: %s" % name)
raise AttributeError(
"'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
jc = self._jdf.apply(name)
return Column(jc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment