<p dir="auto">Using pandas version 0.23.1 and 0.23.2 from conda-forge.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd
df = pd.DataFrame({'a': [10, 20, 30]})

# with list indexer, iloc works as expected
L = [-1, 0, 1]
df.iloc[L]
assert L == [-1, 0, 1]

# with Series indexer, iloc mutates the Series!
s = pd.Series(L)
df.iloc[s]
assert (s == [2, 0, 1]).all()  # wrong!
assert (s == L).all()  # fails!

# with array indexer, iloc mutates the array!
a = np.array(L)
df.iloc[a]
assert (a == [2, 0, 1]).all()  # wrong!
assert (a == L).all()  # fails!"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'a'</span>: [<span class="pl-c1">10</span>, <span class="pl-c1">20</span>, <span class="pl-c1">30</span>]})

<span class="pl-c"># with list indexer, iloc works as expected</span>
<span class="pl-v">L</span> <span class="pl-c1">=</span> [<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>]
<span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-v">L</span>]
<span class="pl-k">assert</span> <span class="pl-v">L</span> <span class="pl-c1">==</span> [<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>]

<span class="pl-c"># with Series indexer, iloc mutates the Series!</span>
<span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-v">L</span>)
<span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-s1">s</span>]
<span class="pl-k">assert</span> (<span class="pl-s1">s</span> <span class="pl-c1">==</span> [<span class="pl-c1">2</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>]).<span class="pl-en">all</span>()  <span class="pl-c"># wrong!</span>
<span class="pl-k">assert</span> (<span class="pl-s1">s</span> <span class="pl-c1">==</span> <span class="pl-v">L</span>).<span class="pl-en">all</span>()  <span class="pl-c"># fails!</span>

<span class="pl-c"># with array indexer, iloc mutates the array!</span>
<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-v">L</span>)
<span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-s1">a</span>]
<span class="pl-k">assert</span> (<span class="pl-s1">a</span> <span class="pl-c1">==</span> [<span class="pl-c1">2</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>]).<span class="pl-en">all</span>()  <span class="pl-c"># wrong!</span>
<span class="pl-k">assert</span> (<span class="pl-s1">a</span> <span class="pl-c1">==</span> <span class="pl-v">L</span>).<span class="pl-en">all</span>()  <span class="pl-c"># fails!</span></pre></div>
<p dir="auto">Negative index values are not in the list of valid indexers for <code class="notranslate">iloc</code> according to the docstring, so maybe this is undefined behavior.  However, it is surprising.  It gives the result one would expect (and does not raise for being out of bounds), but with an unexpected side effect.</p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [31]: import pandas as pd

In [32]: import numpy as np

In [33]: a = np.array([1, 2, -1])

In [34]: b = pd.DataFrame([100, 101, 102], index=[1, 2, 3], columns=['col'])

In [35]: b.iloc[a]
Out[35]:
   col
2  101
3  102
3  102

In [36]: a
Out[36]: array([1, 2, 2])

"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">31</span>]: <span class="pl-s1">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-v">In</span> [<span class="pl-c1">32</span>]: <span class="pl-s1">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-v">In</span> [<span class="pl-c1">33</span>]: <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>])

<span class="pl-v">In</span> [<span class="pl-c1">34</span>]: <span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>([<span class="pl-c1">100</span>, <span class="pl-c1">101</span>, <span class="pl-c1">102</span>], <span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>], <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'col'</span>])

<span class="pl-v">In</span> [<span class="pl-c1">35</span>]: <span class="pl-s1">b</span>.<span class="pl-s1">iloc</span>[<span class="pl-s1">a</span>]
<span class="pl-v">Out</span>[<span class="pl-c1">35</span>]:
   <span class="pl-s1">col</span>
<span class="pl-c1">2</span>  <span class="pl-c1">101</span>
<span class="pl-c1">3</span>  <span class="pl-c1">102</span>
<span class="pl-c1">3</span>  <span class="pl-c1">102</span>

<span class="pl-v">In</span> [<span class="pl-c1">36</span>]: <span class="pl-s1">a</span>
<span class="pl-v">Out</span>[<span class="pl-c1">36</span>]: <span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">2</span>])
</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">The array a is modified after the iloc operation from array([ 1,  2, -1]) to array([1, 2, 2]).  The indexer should not be modified.</p>
<h4 dir="auto">Expected Output</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [39]: a
Out[39]: array([ 1,  2, -1])
"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">39</span>]: <span class="pl-s1">a</span>
<span class="pl-v">Out</span>[<span class="pl-c1">39</span>]: <span class="pl-en">array</span>([ <span class="pl-c1">1</span>,  <span class="pl-c1">2</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>])</pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.14.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 3.10.0-327.36.3.el7.x86_64<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: C<br>
LANG: en_US.UTF-8<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.22.0<br>
pytest: 3.5.0<br>
pip: 9.0.3<br>
setuptools: 39.0.1<br>
Cython: 0.28.2<br>
numpy: 1.14.2<br>
scipy: 1.0.1<br>
pyarrow: 0.9.0<br>
xarray: 0.10.2<br>
IPython: 5.6.0<br>
sphinx: 1.7.2<br>
patsy: 0.5.0<br>
dateutil: 2.7.2<br>
pytz: 2018.4<br>
blosc: None<br>
bottleneck: 1.2.1<br>
tables: 3.4.2<br>
numexpr: 2.6.4<br>
feather: None<br>
matplotlib: 2.2.2<br>
openpyxl: 2.5.2<br>
xlrd: 1.1.0<br>
xlwt: 1.3.0<br>
xlsxwriter: 1.0.2<br>
lxml: 4.2.1<br>
bs4: 4.3.2<br>
html5lib: 0.999<br>
sqlalchemy: 1.2.6<br>
pymysql: None<br>
psycopg2: 2.7.4 (dt dec pq3 ext lo64)<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>