Skip to content

QST: why do we compute hash here #36285

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

Closed
1 of 2 tasks
danielhrisca opened this issue Sep 11, 2020 · 2 comments
Closed
1 of 2 tasks

QST: why do we compute hash here #36285

danielhrisca opened this issue Sep 11, 2020 · 2 comments

Comments

@danielhrisca
Copy link
Contributor

danielhrisca commented Sep 11, 2020

  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.


Question about pandas

In pandas.core.indexes.base hash is called here and the value is not used.

Why is this done?

@danielhrisca danielhrisca added Needs Triage Issue that has not been reviewed by a pandas team member Usage Question labels Sep 11, 2020
@jreback
Copy link
Contributor

jreback commented Sep 11, 2020

so we get the right kind of error on unhashables. simpler to do it here than directly in the indexing code.

In [29]: 1 in pd.Index([1, 2])                                                                                                                                   
Out[29]: True

In [30]: [] in pd.Index([1, 2])                                                                                                                                  
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-aed417339954> in <module>
----> 1 [] in pd.Index([1, 2])

/home/tsdist/vats_deployments/modeling.env.interactive-4d8c1c87-b253-4083-a330-ac480ba587f4/ts/modeling/environment/interactive/../../../../ext/public/python/pandas/1/0/5/dist/lib/python3.6/pandas/core/indexes/numeric.py in __contains__(self, key)
    230         Check if key is a float and has a decimal. If it has, return False.
    231         """
--> 232         hash(key)
    233         try:
    234             if is_float(key) and int(key) != key:

TypeError: unhashable type: 'list'

@jreback jreback closed this as completed Sep 11, 2020
@jreback jreback added this to the No action milestone Sep 11, 2020
@jreback jreback removed the Needs Triage Issue that has not been reviewed by a pandas team member label Sep 11, 2020
@danielhrisca
Copy link
Contributor Author

Thank you for the details!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants