Showing columns in pandas
<p>I have a term x document matrix in pandas (made from a CSV) of the form:</p>

<pre><code>cheese, milk, bread, butter
0,2,1,0
1,1,0,0
1,1,1,1
0,1,0,1 
</code></pre>

<p>So if I say '<em>give me the columns at index 1 and 2 where the values of a given row are both > 0</em>'. </p>

<p>I want to end up with this:</p>

<pre><code>cheese, milk,
[omitted]
1,1
1,1
[omitted]
</code></pre>

<p>This way, I can sum the <code>number of rows</code> / <code>number of documents</code> and arrive at a frequent itemset i.e. <code>(cheese, milk) --[2/4 support]</code></p>

<p>I've tried this approach as indicated on a seperate stackoverflow thread:</p>

<pre><code>fil_df.select([fil_df.columns[1] &gt; 0 and fil_df.columns[2] &gt; 0], [fil_df.columns[1], fil_df.columns[2]])
</code></pre>

<p>But it is not working for me sadly. I'm getting the error:</p>

<blockquote>
  <p>TypeError: unorderable types: str() > int()</p>
</blockquote>

<p>Which I don't know how to fix as I can't make my row's cells be <code>integers</code> when I make the dataframe from a csv.</p>

<pre><code>df.loc[[1, 2], df.loc[[1, 2]].gt(0).all()]
</code></pre>

<p><a href="http://i.stack.imgur.com/qHCu1.png" rel="nofollow"><img src="http://i.stack.imgur.com/qHCu1.png" alt="enter image description here"></a></p>

python pandas indexing condition multiple-columns