title: Python Pandas: AttributeError: 'str' object has no attribute 'loc'
body: <p>Working with dataframe df:</p>
  
  <pre><code>Count
  1
  2
  3
  4
  5
  </code></pre>
  
  <p>Want to add second column, that categorizes everything above 3 as '4+' - needed output:</p>
  
  <pre><code>Count | Category
  1        1
  2        2
  3        3
  4        4+
  5        4+
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>df['Category'] = df['Count']
  df = df.loc[df['Count'] &gt; 3, 'Category'] = '4+'
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre><code>AttributeError: 'str' object has no attribute 'loc'
  </code></pre>