I have a script that includes getting the difference between two dates in months. Initially, I created this script with pandas 1.5.3 and things worked as I expected. However, when I switched environments and used pandas 2.0.3, things changed enough the end results. After some investigating, I traced the problem to the fact that when I perform arithmetic operations on datetime objects, I would get slightly different results in these two pandas versions. For example:
import pandas as pd
import numpy as np
date1 = pd.to_datetime('2022-07-25')
date2 = pd.to_datetime('2023-07-25')
diff = (date2-date1)/np.timedelta64(1, 'M')
print(diff)
Pandas 1.5.3: 11.992
Pandas 2.0.3: 11.774
I tried reading through some of the release notes of pandas > 2.0, but didn't find anything relevant to this? Did I miss something? Can anyone explain this difference?