I have a multi index data frame shown below:
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
I am iterating over the rows and getting the index wherever there is a value 'panning' in the panning column by
ide=[]
for index,row in dfs.iterrows():
if [row[:, 'Panning'][row[:, 'Panning'] == 'Panning']]:
ide.append(row[:, 'Panning'][row[:, 'Panning'] == 'Panning'].index.tolist())
print ide
If I execute the above code I get the output
[[],[],[1],[2],[],[1]]
which represents the index where the value is panning
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
[[],[],[1,7.0],[2,3.0],[],[1,10]]
Basically I need the O/P as combination of the index where the value is panning and the subsequent value in the seconds column