Getting column values from multi index data frame pandas
<p>I have a multi index data frame shown below:</p>

<pre><code>    1                2

panning  sec        panning     sec

 None    5.0        None        0.0
 None    6.0        None        1.0
Panning  7.0        None        2.0 
 None    8.0        Panning     3.0
 None    9.0        None        4.0
 Panning  10.0      None        5.0
</code></pre>

<p>I am iterating over the rows and getting the index wherever there is a value 'panning' in the panning column by</p>

<pre><code> ide=[]
 for index,row in dfs.iterrows():
        if [row[:, 'Panning'][row[:, 'Panning'] == 'Panning']]:
               ide.append(row[:, 'Panning'][row[:, 'Panning'] == 'Panning'].index.tolist())

print ide
</code></pre>

<p>If I execute the above code I get the output </p>

<pre><code>[[],[],[1],[2],[],[1]]
</code></pre>

<p>which represents the index where the value is panning</p>

<p>Now, I also want to get the corresponding sec value also like, for example for row 3 for value panning I would like to get sec value 7.0 along with index 1. I would like O\P to be</p>

<pre><code>[[],[],[1,7.0],[2,3.0],[],[1,10]]
</code></pre>

<p>Basically I need the O/P as combination of the index where the value is panning and the subsequent value in the seconds column.</p>

<p><code>df.iterrows()</code> return a <code>Series</code>, if you want the original <code>index</code> you need to call the <code>name</code> of that <code>Series</code> such has:</p>

<pre><code>for index,row in df.iterrows():
    print row.name
</code></pre>

python pandas