Find integer row-index from pandas index
<p>The following code find index where df['A'] == 1</p>

<pre><code>import pandas as pd
import numpy as np
import random

index = range(10)
random.shuffle(index)
df = pd.DataFrame(np.zeros((10,1)).astype(int), columns = ['A'], index = index)

df.A.iloc[3:6] = 1
df.A.iloc[6:] = 2

print df

print df.loc[df['A'] == 1].index.tolist()
</code></pre>

<p>It returns pandas index correctly. How do I get the integer index ([3,4,5]) instead using pandas API?</p>

<pre><code>   A
8  0
4  0
6  0
3  1
7  1
1  1
5  2
0  2
2  2
9  2
[3, 7, 1]
</code></pre>

<p>what about?</p>

<pre><code>In [12]: df.index[df.A == 1]
Out[12]: Int64Index([3, 7, 1], dtype='int64')
</code></pre>

<p>or (depending on your goals):</p>

<pre><code>In [15]: df.reset_index().index[df.A == 1]
Out[15]: Int64Index([3, 4, 5], dtype='int64')
</code></pre>

<p>Demo:</p>

<pre><code>In [11]: df
Out[11]:
   A
8  0
4  0
6  0
3  1
7  1
1  1
5  2
0  2
2  2
9  2

In [12]: df.index[df.A == 1]
Out[12]: Int64Index([3, 7, 1], dtype='int64')

In [15]: df.reset_index().index[df.A == 1]
Out[15]: Int64Index([3, 4, 5], dtype='int64')
</code></pre>

python pandas dataframe row indices