title: Defining a date from a column in Python
body: <p>I have a table of codes and dates that is continuously growing from another source, e.g.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Code</th>
  <th>Name</th>
  <th>Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>RM1377</td>
  <td>a</td>
  <td>30/07/2022</td>
  </tr>
  <tr>
  <td>RM1377</td>
  <td>b</td>
  <td>30/07/2022</td>
  </tr>
  <tr>
  <td>RM1377</td>
  <td>c</td>
  <td>30/07/2022</td>
  </tr>
  <tr>
  <td>RM1377</td>
  <td>d</td>
  <td>30/07/2022</td>
  </tr>
  <tr>
  <td>RM1378</td>
  <td>e</td>
  <td>07/08/2022</td>
  </tr>
  <tr>
  <td>RM1378</td>
  <td>f</td>
  <td>07/08/2022</td>
  </tr>
  <tr>
  <td>RM1378</td>
  <td>g</td>
  <td>07/08/2022</td>
  </tr>
  <tr>
  <td>RM1378</td>
  <td>h</td>
  <td>07/08/2022</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And I want to be able to enter a Code into an input, and then retrieve the date associated with the Code, so that I can query on it.</p>
  <p>How can I define DM1377 as always being 30/07/2022, and account for DM1389 potentially being in the table with another date?</p>
  <p>I.e. instead of <code>cruise_date = datetime.date(2022, 7, 30)</code> I imagine it would be something like <code>cruise_date = datetime.date(Voyage_date)</code></p>
  <pre class="lang-py prettyprint-override"><code>from traceback import print_tb
  import pandas as pd
  from dateutil.relativedelta import relativedelta
  import datetime
  
  #voyage_id = input('Voyage ID:')
  
  # Retrieve the data and assign headers
  df = pd.read_csv(&quot;dcl_manifest_20220729.csv&quot;, usecols=[0,2,5,6,7,8], names=['Cruise', 'Booking reference', 'First name', 'Last name', 'DoB', 'Cancellation'])
  df[['Cruise', 'Booking reference', 'First name', 'Last name', 'DoB', 'Cancellation']]
  
  
  # Convert DoB column to dates 
  df[&quot;DoB&quot;] = pd.to_datetime(df[&quot;DoB&quot;])
  
  # Define the cruise date
  cruise_date = datetime.date(2022, 7, 30)
  
  # Calucate 5 years ago to indentify under 5s
  years_ago = cruise_date - relativedelta(years=5)
  
  # Query under 5s and print the output
  u5 = df.query('DoB &gt; @years_ago &amp; Cruise == &quot;DM1377&quot; &amp; Cancellation == &quot;No&quot;')
  print(&quot;Number of under 5s: &quot; + str(len(u5.index)))
  </code></pre>