8000 Implement _make_accessor classmethod for PandasDelegate by jbrockmendel · Pull Request #17166 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Implement _make_accessor classmethod for PandasDelegate #17166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixups suggested by reviewers
  • Loading branch information
jbrockmendel committed Aug 4, 2017
commit 9c0ae3f756cef3ecdb38c0144139843d1ee929d0
10 changes: 4 additions & 6 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class PandasDelegate(PandasObject):

@classmethod
def _make_accessor(cls, data):
raise NotImplementedError("_make_accessor should be implemented"
"by subclass. It should return an instance"
raise AbstractMethodError("_make_accessor should be implemented"
"by subclass and return an instance"
"of `cls`.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use instead: "_make_accessor should be implemented by subclass and return an instance of cls."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have AbstracMethodError for this


def _delegate_property_get(self, name, *args, **kwargs):
Expand Down Expand Up @@ -239,10 +239,8 @@ class AccessorProperty(object):

def __init__(self, accessor_cls, construct_accessor=None):
self.accessor_cls = accessor_cls
if construct_accessor is None:
# We are assuming that `_make_accessor` classmethod exists.
construct_accessor = accessor_cls._make_accessor
self.construct_accessor = construct_accessor
self.construct_accessor = (construct_accessor or
accessor_cls._make_accessor)
self.__doc__ = accessor_cls.__doc__

def __get__(self, instance, owner=None):
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,5 @@ def _make_accessor(cls, data):
try:
return maybe_to_datetimelike(data)
except Exception:
raise AttributeError("Can only use .dt accessor with datetimelike "
"values")
raise AttributeError("Can only use .dt accessor with "
"datetimelike values")
0