How can you just get the index of an already selected row in pandas?
<pre><code>In [60]: print(row.index)
Int64Index([15], dtype='int64')
</code></pre>

<p>I already know that the row number is 15, in this example. But I don't need to know it's type or anything else. The variable which stores it would do something based on what that number is. </p>

<p>There was something else about pandas I was wondering about. Suppose that this only returns one row: </p>

<pre><code>row = df[df['username'] == "unique name"]  
</code></pre>

<p>Is it any less proper to use methods like loc, iloc, etc? They still work and everything, but I was curious if it would still be done this way in larger projects.. Are there preferred methods if it's just one row, as opposed to a list of rows. </p>

<p>If you write</p>

<pre><code>row.index[0]
</code></pre>

<p>then you will get, in your case, the integer 15.</p>

<hr>

<p>Note that if you check</p>

<pre><code>dir(pd.Int64Index)
</code></pre>

<p>You can see that it includes the list-like method <code>__getitem__</code>.</p>

python pandas