title: AttributeError: 'str' object has no attribute 'loc'
body: <p>Trying to bucket the age values using a for loop as below </p>
  
  <pre><code>for dataset in train:
  dataset.loc[(dataset['age'] &gt; 15) &amp; (dataset['age'] &lt;= 25), 'age'] = 1
  dataset.loc[(dataset['age'] &gt; 25) &amp; (dataset['age'] &lt;= 35), 'age'] = 2
  dataset.loc[(dataset['age'] &gt; 35) &amp; (dataset['Age'] &lt;= 45), 'age'] = 3
  dataset.loc[(dataset['age'] &gt; 45) &amp; (dataset['age'] &lt;= 55), 'age'] = 4
  dataset.loc[ dataset['age'] &gt; 55, 'age']}
  </code></pre>
  
  <p>Getting error :</p>
  
  <pre><code>AttributeError: 'str' object has no attribute 'loc'
  </code></pre>
  
  <p>i am looking for my dataset to be like the one below:</p>
  
  <pre><code>age(in existing dataset)           age(in existing dataset)
  25                                 1
  35                                 2
  45                                 3
  73                                 4
  </code></pre>