-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: np array indexer modifed in iloc #21867
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 14 commits
8c6161c
f71eb24
594e805
9a9054d
e0e82f3
7bd51cb
5d65995
5db95df
376fb3b
7a5357c
a5c1a13
350680e
77bd054
cb5fa3e
e15b9d2
4e3d34b
4ce3a47
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 |
---|---|---|
|
@@ -126,6 +126,23 @@ def test_iloc_getitem_neg_int(self): | |
typs=['labels', 'mixed', 'ts', 'floats', 'empty'], | ||
fails=IndexError) | ||
|
||
def test_iloc_array_not_mutating_negative_indices(self): | ||
|
||
# GH 21867 | ||
array_with_neg_numbers = np.array([1, 2, -1]) | ||
array_copy = array_with_neg_numbers.copy() | ||
df = pd.DataFrame({ | ||
'A': [100, 101, 102], | ||
'B': [103, 104, 105], | ||
'C': [106, 107, 108]}, | ||
index=[1, 2, 3]) | ||
df.iloc[array_with_neg_numbers] | ||
tm.assert_numpy_array_equal(array_with_neg_numbers, array_copy) | ||
|
||
df.iloc[:, array_with_neg_numbers] | ||
tm.assert_numpy_array_equal(array_with_neg_numbers, array_copy) | ||
|
||
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. Should only need one blank line here (think this will fail LINTing) 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. I can't find LINTing in the contributing guide. Can I LINT myself and how exactly do you guys do that? 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. http://pandas-docs.github.io/pandas-docs-travis/contributing.html#python-pep8 has the quick version, but that doesn't check everything. The actual command run during CI is https://travis-ci.org/pandas-dev/pandas/jobs/403382274#L2928 is the line causing this PR to fail. 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.
|
||
|
||
def test_iloc_getitem_list_int(self): | ||
|
||
# list of ints | ||
|
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 the issue number here as a comment