I have a pandas dataframe, 'df', where there is an original column with dates in datetime format. I set a hard date as a variable:
hard_date = datetime.date(2013, 5, 2)
I then created a new column in my df with the difference between the values in the date column and the hard_date...
df['days_from'] = df['date'] - hard_date
This produced a good output. for instance, when I print the first cell in the new column it shows:
print (df['days_from'].iloc[0])
28 days 00:00:00
But now I want to convert the new column to just the number of days as an integer. I thought about just taking the first 2 characters, but many of the values are negative, so I am seeking a better route.
Any thoughts on an efficient way to convert the column to just the integer of the days?
Thanks