title: DataFrame can't be iterated through: getting following error: tuple indices must be integers or slices, not str
body: <p>I've been trying to debug my code for the last 30 minutes to no avail, maybe you can help?</p>
  
  <p>The error lies withing line 17, but I'm truly clueless to why it's happening.</p>
  
  <p>So, I'm using a dictionary in order to store the data that my function <code>is_nontrivial_reverse_number()</code> returns, which is a <code>boolean</code> type. I iterate through it and insert all of the values from <code>0</code> to <code>1100</code>.</p>
  
  <p>I then insert my dictionary into a <code>DataFrame</code> with the <code>pandas</code> library.</p>
  
  <p>Then I iterate through my dataFrame in order to retrieve the count of the values that are set to true.</p>
  
  <p>But the problem is that <code>row["nonTrivial"]</code> doesn't seem to be working, even though I used the same function on a different dictionary and dataframe set.</p>
  
  <pre><code>import pandas as pd2
  
  dic2 = {'nonTrivial': [is_nontrivial_reverse_number(x) for x in range(0, 1100)]}
  dic2
  
  df2 = pd2.DataFrame(dic2)
  df2 = df2.set_index('nonTrivial')
  
  #df2.head()
  ##df2.shape
  #df.dtypes
  
  
  
  for row in df2.iterrows():
      if (row["nonTrivial"]==True):
          n = n+1
  print (n)
  </code></pre>
  
  <p>Expected result : <code>n=2</code></p>
  
  <h2>what I get:</h2>
  
  <pre class="lang-none prettyprint-override"><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-314-ce7c400929e6&gt; in &lt;module&gt;
       15
       16 for row in df2.iterrows():
  ---&gt; 17     if (row["nonTrivial"]==True):
       18         n = n+1
       19 print (n)
  
  TypeError: tuple indices must be integers or slices, not str
  </code></pre>