python pandas dataframe - can't figure out how to lookup an index given a value from a df
<p>I have 2 dataframes of numerical data. Given a value from one of the columns in the second df, I would like to look up the index for the value in the first df. More specifically, I would like to create a third df, which contains only index labels - using values from the second to look up its coordinates from the first.</p>

<pre><code>listso = [[21,101],[22,110],[25,113],[24,112],[21,109],[28,108],[30,102],[26,106],[25,111],[24,110]]
data = pd.DataFrame(listso,index=list('abcdefghij'), columns=list('AB'))
rollmax = pd.DataFrame(data.rolling(center=False,window=5).max())
</code></pre>

<p>So for the third df, I hope to use the values from <code>rollmax</code> and figure out which row they showed up in <code>data</code>.  We can call this third df <code>indexlookup</code>.</p>

<p>For example, <code>rollmax.ix['j','A'] = 30</code>, so <code>indexlookup.ix['j','A'] = 'g'</code>.</p>

<p>Thanks!</p>

<p>You can build a Series with the indexing the other way around:</p>

<pre><code>mapA = pd.Series(data.index, index=data.A)
</code></pre>

<p>Then <code>mapA[rollmax.ix['j','A']]</code> gives <code>'g'</code>.</p>

python pandas indexing dataframe lookup