title: How to convert time of the date and count the days in python?
body: <p>I have a dataset about users taking online courses. It has features like, 'id', 'event', 'time'. I groupby them and want to know the frequency of a user doing every event on specific days. I want to count them in days.</p>
  
  <pre><code>lt = log_train.groupby(['enrollment_id','event','time']).size()
  print(lt)
  
  
  enrollment_id  event       time
  1              access  2014-06-14T09:38:39    2
                         2014-06-14T09:38:48    1
                         2014-06-19T06:21:16    2
                         2014-06-19T06:21:32    1
                         2014-06-19T06:21:45    1
                                             ..
  200887     navigate    2014-07-24T03:27:16    1
  200887     navigate    2014-07-24T03:27:16    1
             page_close  2014-07-24T04:19:55    1
             video       2014-07-24T04:19:57    1
  200888     access      2014-07-24T03:48:14    2
             discussion  2014-07-24T03:47:57    1
             navigate    2014-07-24T03:47:17    1
                         2014-07-24T03:47:28    1
                         2014-07-24T03:48:01    1
  </code></pre>
  
  <p>From the information I have seen in another dataset there are userIDs, courseIDs and course range time. </p>
  
  <pre><code>usercourse = pd.merge(enroll,date,how="left", on= 'course_id' )
  
  
  
   enrollment_id                          username  \
  
  0                   1  9Uee7oEuuMmgPx2IzPfFkWgkHZyPbWr0   
  1                   3  1qXC7Fjbwp66GPQc6pHLfEuO8WKozxG4   
  2                   4  FIHlppZyoq8muPbdVxS44gfvceX9zvU7 
  
                             course_id        from          to  
  0       DPnLzkJJqOOPRJfBxIHbQEERiYHu5ila  2014-06-12  2014-07-11  
  1       7GRhBDsirIGkRZBtSMEzNTyDr2JQm4xx  2014-06-19  2014-07-18  
  2       DPnLzkJJqOOPRJfBxIHbQEERiYHu5ila  2014-06-12  2014-07-11 
  </code></pre>
  
  <p>Every single user has only 1 course and all the courses have the same range with 30 days. So what I want to have should be similar like this,</p>
  
  <pre><code>enrollment_id  event      #ofDays   #ofActionTimes
  1              access      2         2
                             10        6
                             30        2
                                     ..
  200887         navigate    23        1
                 page_close  30        1
                 video       1         1
  200888         access      12        2
                 discussion  2         1
                 navigate    5         3
                             29        4  
  
  **#ofDays means at the Nth day of a course.
  #ofActionTimes means how often an event happens on the Nth day.**
  </code></pre>
  
  <p>Since every course started from different dates I have no idea how to generate this data form on python.<br>
  Hope someone could help me to solve the problem!</p>