Python pandas: Select columns where a specific row satisfies a condition
<p>I have a dataframe dfall where there is a row labeled 'row1' with values 'foo' and 'bar'. I want to select only columns of dfall where 'row1' has the value 'foo'.</p>

<p>In other words:</p>

<pre><code>dfall= pd.DataFrame([['bar','foo'],['bla','bli']], columns=['col1','col2'], index=['row1','row2'])
</code></pre>

<p>I want as result the column 'col2'containing: <code>['foo','bli']</code></p>

<p>I tried:</p>

<pre><code>dfall[dfall.loc['row1'].isin(['foo'])]
</code></pre>

<p>I get the error </p>

<pre><code>IndexingError: Unalignable boolean Series key provided
</code></pre>

<p>Can anybody help me with the command? Thanks in advance!</p>

<p>Using EdChum's answer, to make it row specific I did: 
df.ix[:,(df.loc['row1'] == 'foo')]</p>

python pandas select