title: Python: How to calculate Difference btw Current Year and Year from Column?
body: <p>I have a column "DateBecameRep_Year" that contains only year values in it (i.e. 1974, 1999, etc.).  I want to create a new column in my dataframe that calculates the difference between the current year and the year in the "DateBecameRep_Year" field.      </p>
  
  <p>Below is the code I tried to use:  </p>
  
  <pre><code>df_DD['DateBecameRep_Year'] = pd.to_datetime(df_DD['DateBecameRep_Year'])
  
  df_DD['Current Year'] = datetime.now().year
  df_DD['Current Year'] = pd.to_datetime(df_DD['Current Year'])
  
  df_DD['Years_Since_BecameRep'] = df_DD['Current Year'] - df_DD['DateBecameRep_Year']  
  df_DD['Years_Since_BecameRep'] = df_DD['Years_Since_BecameRep'] / np.timedelta64(1, 'Y')
  
  df_DD['Years_Since_BecameRep'].head()
  </code></pre>
  
  <p>This is the output I get which looks very strange: </p>
  
  <p><a href="https://i.stack.imgur.com/sXDoq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sXDoq.png" alt="enter image description here"></a></p>
  
  <p>My hypothesis is that this has something to do with the following: </p>
  
  <p><a href="https://i.stack.imgur.com/Ndq5k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ndq5k.png" alt="enter image description here"></a></p>
  
  <p>Any help is greatly appreciated!  </p>