title: python - how to count user has transactions in 1 year
body: <pre><code>dt          userid  amt 
  6/17/2019       1   200
  7/30/2019       1   400
  8/17/2019       1   300
  4/14/2019       1   140
  5/19/2019       1   230
  1/7/2019        2   170
  2/25/2019       2   450
  3/4/2019        2   350
  4/17/2019       2   76
  5/12/2019       2   900
  6/30/2019       2   300
  7/20/2019       2   40
  8/21/2019       2   60
  9/20/2019       2   50
  10/9/2019       2   40
  11/27/2019      2   70
  12/11/2019      2   80
  4/9/2019        3   30
  10/4/2019       3   20
  10/18/2019      3   10
  
  
  dt            user_id    transaction     not_active
  8/17/2019        1          no               9  
  12/11/2019       2          yes              5
  10/18/2019       3          no               7
  </code></pre>
  
  <p>My data is 1-year in 2019 from January to December. I want to know...</p>
  
  <p>1) count each user has transactions 12 months or not?   </p>
  
  <pre><code>  yes means a user has transaction 12 month
  </code></pre>
  
  <p>2) when is the latest date?</p>
  
  <p>3) is it active? >> mean how long do users not active, now is May 2020.  </p>
  
  <pre><code>  user1 last transaction August, and now is May, then 9 months is not active
  
    user2 last transaction December, and now is May, then 5 months is not active
  </code></pre>