-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG #19860 Corrected use of mixed indexes with .at #22436
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
Changes from 1 commit
f47ba8e
46025b0
bef65fc
9e55818
9a50f04
fcb1f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -666,6 +666,20 @@ def test_index_type_coercion(self): | |
idxr(s2)['0'] = 0 | ||
assert s2.index.is_object() | ||
|
||
@pytest.mark.parametrize("index,val", [ | ||
(Index([0, 1, '2']), '1'), | ||
(Index([0, 1, '2']), 2), | ||
]) | ||
def test_mixed_index_not_contains(self, index, val): | ||
assert val not in index | ||
|
||
@pytest.mark.parametrize("index,val", [ | ||
(Index([0, 1, '2']), 0), | ||
(Index([0, 1, '2']), '2'), | ||
]) | ||
def test_mixed_index_contains(self, index, val): | ||
assert val in index | ||
|
||
|
||
class TestMisc(Base): | ||
|
||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a gh comment with the issue number There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
assert s.iat[i] == i + 1 | ||
|
||
def test_mixed_index_assignment(self): | ||
s = Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 1, 2]) | ||
s.at['a'] = 11 | ||
assert s.iat[0] == 11 | ||
s.at[1] = 22 | ||
assert s.iat[3] == 22 | ||
|
||
def test_mixed_index_no_fallback(self): | ||
s = Series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 1, 2]) | ||
with pytest.raises(KeyError): | ||
s.at[0] | ||
with pytest.raises(KeyError): | ||
s.at[4] | ||
|
||
def test_rhs_alignment(self): | ||
# GH8258, tests that both rows & columns are aligned to what is | ||
# assigned to. covers both uniform data-type & multi-type cases | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_index_not_contains
andtest_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?