I think this should be simple, but what I saw are methods that include iterating over the dataframe date fields to determine the difference between the two dates. And I have problems with that. I am familiar with MSSQL DATEDIFF, so I thought Pandas datetime would have something similar. I may be doing this, but I miss it.
Does Pandonic have a way of determining the number of months as an integer between two dates (datetime) without the need for repetition? Bearing in mind that there are potentially millions of lines, so performance is a consideration.
Dates are datetime objects, and the result will look like this: a new “Month” column:
Date1 Date2 Months
2016-04-07 2017-02-01 11
2017-02-01 2017-03-05 1
source
share