title: Pandas dataframe Sum for specific years
body: <p>I just started using Pandas for my analytics work.</p>
  
  <p>I have a dataframe in Pandas with over 2 million rows, suppose it's called DF.
  I need to create a variable that shows me the SUM of a column called "Total Records" but separate it by year, so lets say, one variable for 2017, another for 2018 and another one for 2019.
  Problem is, my DATE column is formatted like so: 1/20/2018
  Is there anything like the SQL syntax:</p>
  
  <pre><code>Select Sum("Total Records") 
  From DF
  Where date like '%2018';
  </code></pre>
  
  <p>?</p>
  
  <p>i have attempted to use df.query('date == 2018')['Total Records'].sum(), but it gives me a syntax error.</p>
  
  <p>Suppose the DF looks like so:</p>
  
  <pre><code>Date      | Total Records
  1-20-2019 | 100
  3-12-2018 | 50
  5-14-2019 | 100
  3-10-2018 | 20   
  </code></pre>
  
  <p>I want it to output the variables like this</p>
  
  <pre><code>TotalRecords2018 = 70;
  TotalRecords2019 = 200;
  </code></pre>