title: Pandas - Add column containing metadata about the row
body: <p>I want to add a column to a Dataframe that will contain a number derived from the number of NaN values in the row, specifically: one less than the number of non-NaN values in the row. </p>
  
  <p>I tried:</p>
  
  <pre><code>for index, row in df.iterrows():
      count = row.value_counts()
      val = sum(count) - 1
      df['Num Hits'] = val
  </code></pre>
  
  <p>Which returns an error:</p>
  
  <pre><code>-c:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.
  Try using .loc[row_index,col_indexer] = value instead
  </code></pre>
  
  <p>and puts the first <em>val</em> value into every cell of the new column. I've tried reading about .loc and indexing in the Pandas documentation and failed to make sense of it. I gather that .loc wants a row_index and a column_index but I don't know if these are pre-defined in every dataframe and I just have to specify them somehow or if I need to "set" an index on the dataframe somehow before telling the loop where to place the new value, <em>val</em>. </p>