I am trying to find the number of days between a list of dates in a Pandas Dataframe and the current date.
I want to create a new column with the number of days between the due dates and the current date. For example:
+---------------------+------------+
| Due Date | Difference |
+---------------------+------------+
| 2019-04-15 00:00:00 | 146 |
| 2019-02-11 00:00:00 | 83 |
| 2019-03-11 00:00:00 | 111 |
| 2019-01-04 00:00:00 | 45 |
| 2019-05-13 00:00:00 | 174 |
+---------------------+------------+
I was trying to do:
current = np.datetime64('today')
df['Difference'] = df['Due Date'] - current
But I was getting wrong numbers. It works fine if I do them individually like:
df['Due Date'][0] - current
Any help would be great. Thanks!
.days