Skip to content
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

FIX hash of DataFrame raises Typerror #3884

Merged
merged 2 commits into from
Jun 13, 2013
Merged

Conversation

hayd
Copy link
Contributor

@hayd hayd commented Jun 13, 2013

fixes #3882

raise TypeError if trying to hash a DataFrame (or Panel etc.).

@@ -594,6 +594,9 @@ def axes(self):
def __repr__(self):
return 'NDFrame'

def __hash__(self):
raise TypeError("unhashable type")
Copy link
Member

Choose a reason for hiding this comment

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

what about

    def __hash__(self):
        raise TypeError('{0!r} objects are mutable, thus they cannot be'
                        ' hashed'.format(self.__class__.__name__))

maybe for series too. i find that error message thoroughly unhelpful, which is so unlike pandas :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, I just recklessly copied the error for numpy...

@hayd
Copy link
Contributor Author

hayd commented Jun 13, 2013

Should any PandasObjects be hashable? (pretty sure answer is yes)

Currently this makes NDFrame not hashable. Changing the message for Series too with your improvement and adding tests :)

@hayd hayd mentioned this pull request Jun 13, 2013
@hayd
Copy link
Contributor Author

hayd commented Jun 13, 2013

All tests pass, so I guess we aren't hashing anything. There were know hashing tests in the docs before.

Merge?

@jreback
Copy link
Contributor

jreback commented Jun 13, 2013

ok by me

hayd added a commit that referenced this pull request Jun 13, 2013
FIX hash of DataFrame raises Typerror
@hayd hayd merged commit 7327d69 into pandas-dev:master Jun 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hashable DataFrames
3 participants