title: Making a categorical variable from a continuous datetime variable
body: <p>I am trying to make a categorical variable from a continuous datetime variable.</p>
  
  <p>Basically if they are between 15 and 25, then Age_category = 1, if they are between 25 and 35, then Age_category = 2.</p>
  
  <p>I've got it so that I can make one condition, this works:</p>
  
  <pre><code>df.loc[(df['Age_days'] &gt; timedelta(days=(25*365)), 'Age2')] = '1'
  </code></pre>
  
  <p>When I try and make two conditions it fails:</p>
  
  <pre><code>df.loc[(df['Age_days'] &gt; timedelta(days=(15*365)) &amp; (df['Age_days'] &lt;= timedelta(days=(25*365)), 'Age_cat'))] = '1'
  </code></pre>
  
  <p>The error I get says that it doesn't like the use of '&amp;':</p>
  
  <pre><code>TypeError: unsupported operand type(s) for &amp;: 'datetime.timedelta' and 'tuple'
  </code></pre>
  
  <p>I've tried replacing &amp; with 'and' but it also doesn't like that:</p>
  
  <pre><code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  
  <p>Any idea how I should fix this?</p>