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

BUG #19860 Corrected use of mixed indexes with .at #22436

Merged
merged 6 commits into from Aug 29, 2018

Conversation

mariuspot
Copy link
Contributor

.at incorrectly disallowed the use of integer indexes when a mixed index was used

s = Series([1,2,3,4,5],index=['a','b','c',1,2])
s.at['a'] # returns 1
s.at[1]   # returns 4
s.at[4]   # raises KeyError, doesn't do fallback indexing

Made sure fallback indexing doesn't happen on mixed indexes

.at incorrectly disallowed the use of integer indexes when a mixed index
was used
disabled fallback indexing when a mixed index is used
@codecov
Copy link

codecov bot commented Aug 21, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@fa47b8d). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #22436   +/-   ##
=========================================
  Coverage          ?   92.03%           
=========================================
  Files             ?      169           
  Lines             ?    50780           
  Branches          ?        0           
=========================================
  Hits              ?    46737           
  Misses            ?     4043           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.44% <100%> (?)
#single 42.22% <33.33%> (?)
Impacted Files Coverage Δ
pandas/core/indexing.py 93.79% <100%> (ø)
pandas/core/indexes/base.py 96.45% <100%> (ø)

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 fa47b8d...fcb1f61. Read the comment docs.

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.

looks pretty good. can you add a whatsnew note in bugfixes indexing for 0.24

@@ -666,6 +666,20 @@ def test_index_type_coercion(self):
idxr(s2)['0'] = 0
assert s2.index.is_object()

@pytest.mark.parametrize("index,val", [
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment with the issue number

Copy link
Contributor

Choose a reason for hiding this comment

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

these tests should be in pandas/tests/indexes/test_base (look for other contains tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test_index_not_contains and test_index_contains are in the same file a few lines above, should I move these up or create pandas/tests/indexes/test_base and move them there?

@@ -710,6 +724,27 @@ def test_float_index_at_iat(self):
for i in range(len(s)):
assert s.iat[i] == i + 1

def test_mixed_index_at_iat(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

move these to pandas/tests/indexing/test_scalar.py (see where other ones are)

Copy link
Contributor

Choose a reason for hiding this comment

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

add a gh comment with the issue number

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the test from the OP (was on dataframe)

s = Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 1, 2])
for el, item in s.iteritems():
assert s.at[el] == item
for i in range(len(s)):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you check that we have similar tests for .loc (I think so), if not can you add a loc version (inside same test is ok). maybe even just add the .loc tests and move from elsewhere.

you can parameterize these over .at / .loc

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

jreback commented Aug 21, 2018

also there might be other .at issues which this closes. pls have a look if you can.

cc @toobaz

Added whatsnew to 0.24
Added issue to tests comments
Moved some test
Added a test from the issue
@pep8speaks
Copy link

pep8speaks commented Aug 21, 2018

Hello @mariuspot! Thanks for updating the PR.

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

Comment last updated on August 27, 2018 at 15:41 Hours UTC

@jreback jreback added this to the 0.24.0 milestone Aug 22, 2018
@jreback
Copy link
Contributor

jreback commented Aug 22, 2018

looks good. can you rebase

@jreback jreback requested a review from toobaz August 22, 2018 10:37
@jreback
Copy link
Contributor

jreback commented Aug 22, 2018

looks like you picked up some other commits, do this
git merge upstream/master and push again

@mariuspot
Copy link
Contributor Author

git merge upstream/master didn't do anything
Not sure what I did now :/
Hope it's ok now

@mariuspot
Copy link
Contributor Author

Ok, I figured out what went wrong with the merge. Should be ok now

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.

lgtm. looks like some extraneous rebase issue. ping on green.

@@ -659,7 +659,11 @@ Indexing
- Fixed ``DataFrame[np.nan]`` when columns are non-unique (:issue:`21428`)
- Bug when indexing :class:`DatetimeIndex` with nanosecond resolution dates and timezones (:issue:`11679`)
- Bug where indexing with a Numpy array containing negative values would mutate the indexer (:issue:`21867`)
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

hve a rebase issue here

@jreback
Copy link
Contributor

jreback commented Aug 23, 2018

lgtm ping on green.

@mariuspot
Copy link
Contributor Author

Looks like travis failed with a segfault on the linker

@mariuspot
Copy link
Contributor Author

@jreback The travis build had a segfault with the linker while setting up the environment. What is the process for that. Is there a way for me to rerun the build or should I make a change and do a new commit?

@jreback jreback merged commit bf67634 into pandas-dev:master Aug 29, 2018
@jreback
Copy link
Contributor

jreback commented Aug 29, 2018

thanks!

@mariuspot mariuspot deleted the issue-19860 branch September 10, 2018 05:48
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 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.

BUG?: .at not working on object indexes containing some integers
3 participants