Skip to content

Conversation

@a1shadows
Copy link

@a1shadows a1shadows commented Aug 15, 2018

  • closes Checking that a pandas.Series.index contains a value #22085
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry
    checks for type using is_float, is_integer_dtype and if key is a float that does not resolve to an equivalent int and Index is int, returns false.

@a1shadows a1shadows changed the title fixes #22085 fixes #22085 (int type pandas.series.index contains float type key bug) Aug 15, 2018
@a1shadows a1shadows closed this Aug 16, 2018
@codecov
Copy link

codecov bot commented Aug 16, 2018

Codecov Report

Merging #22366 into master will decrease coverage by <.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22366      +/-   ##
==========================================
- Coverage   92.05%   92.05%   -0.01%     
==========================================
  Files         169      169              
  Lines       50709    50712       +3     
==========================================
+ Hits        46679    46681       +2     
- Misses       4030     4031       +1
Flag Coverage Δ
#multiple 90.45% <66.66%> (-0.01%) ⬇️
#single 42.25% <33.33%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.38% <66.66%> (-0.05%) ⬇️
pandas/core/frame.py 97.24% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a2d1cf...ae5796b. Read the comment docs.

@a1shadows a1shadows reopened this Aug 16, 2018
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

tests and pls add a whatsnew entry for 0.24

def __contains__(self, key):
hash(key)
try:
if type(key) == float and self.dtype == int:
Copy link
Contributor

Choose a reason for hiding this comment

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

use is_float(key) and is_integer_dtype(self.dtype)

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry, I'm very new to this. But could you please tell me what to add to whatsnew,

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Bug labels Aug 16, 2018
@jreback
Copy link
Contributor

jreback commented Aug 16, 2018

note that this duplicates #22360

try:
if is_float(key) and is_integer_dtype(self.dtype):
if key != int(key):
return False
Copy link
Member

Choose a reason for hiding this comment

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

I would put this outside of the try/except block

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

@jorisvandenbossche I think it can't pass the test!

Copy link
Member

Choose a reason for hiding this comment

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

So it fails when key is NaN ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think so. The block is needed.

@pep8speaks
Copy link

pep8speaks commented Aug 16, 2018

Hello @a1shadows! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on August 16, 2018 at 11:59 Hours UTC

@a1shadows
Copy link
Author

duplicate PR

@a1shadows a1shadows closed this Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Indexing Related to indexing on series/frames, not to indexes themselves

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checking that a pandas.Series.index contains a value

5 participants