how to filter by iloc
<p>I have a dataframe that has 2 columns. the second column is one of only a few values. I want to make a method that returns a dataframe where only the rows where that column had a specific value are included.</p>

<p>I had this working with this this code:</p>

<pre><code>def filterOnName(df1):
    d1columns = df1.columns
    return df1[df1[d1columns[1]] == "Jimmy"]
</code></pre>

<p>Seems quite convoluted doesn't it? I guess there's  a pandas method called iloc that should clean this up abit but I'm having trouble implementing it. Can you explain what I'm doing wrong?</p>

<pre><code>def filterOnName(df1):
    return df1[df1.iloc[1] == "Jimmy"]
</code></pre>

<p>Thanks for your help!</p>