You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two series that are like-indexed datetimes. I'm trying to do simple math operations on them and noticed the results don't match what I'd expect. Specifically, subtracting one datetime from the other doesn't always result in subtraction across the aligned indices. Transforming the series to a dataframe with a dummy column gets us closer but the type manipulation isn't correct.
printfirstOrderNotEval.loc[site]
printfirstEvalOrder.loc[site]
printtype(firstOrderNotEval.loc[site])
printtype(firstEvalOrder.loc[site])
### output:#2008-08-21 00:00:00#2013-09-10 00:00:00# <class 'pandas.tslib.Timestamp'># <class 'pandas.tslib.Timestamp'>timeToFirstNonEvalPurchase_doesntWork= ((firstOrderNotEval-firstEvalOrder)/np.timedelta64(1,'D'))
timeToFirstNonEvalPurchase= ((firstOrderNotEval.to_frame('a') -firstEvalOrder.to_frame('a'))/np.timedelta64(1,'D'))['a']
printtimeToFirstNonEvalPurchase_doesntWork.loc[2898717]
printtimeToFirstNonEvalPurchase.loc[2898717]
### output:# nan# -1846 nanoseconds # note should be 1846 days
Subtracting individual elements gives the correct result but as a datetime.timedelta type. subtracting the series directly gives NaT:
I have two series that are like-indexed datetimes. I'm trying to do simple math operations on them and noticed the results don't match what I'd expect. Specifically, subtracting one datetime from the other doesn't always result in subtraction across the aligned indices. Transforming the series to a dataframe with a dummy column gets us closer but the type manipulation isn't correct.
Subtracting individual elements gives the correct result but as a datetime.timedelta type. subtracting the series directly gives NaT:
Perhaps this has to do with the timestamp type itself given the following example:
Note that the following have different results based on how the divide by timedelta64 is performed:
The attached pickle files (as .jpg) include the series used in this example
The text was updated successfully, but these errors were encountered: