Pandas: Get corresponding column value in row based on unique value
<p>I've figured out how to get the information I want, but I would be surprised if there is not a better, more readable way to do so.</p>
<p>I want to get the value in a different column in the row that holds the data element I specify. For example, what is the value in column <code>b</code> that corresponds to the value of <code>11</code> in column <code>a</code>.</p>
<pre><code>&gt;&gt;&gt; df
    a   b   c
0  10  20  30
1  11  21  31
2  12  22  32

&gt;&gt;&gt; df['b'][df[df['a'] == 11].index.tolist()].tolist()
[21]
</code></pre>
<p>This is how I currently solved it, but in practice my dataframes are not named so concisely and I have long strings as column names so the line gets hard to read.</p>
<p>EDIT: If the value in 'a' is not unique is there also a way to get all corresponding values in 'b'?</p>