um8ra
um8ra

Reputation: 195

Python Pandas Timestamp Subtraction vs. Numpy

I am having an odd issue when subtracting Timestamps in pandas (version 15.2) on Python 3.4

Incorrect

y = pd.Timestamp('2015-04-14 00:00:00')
z = pd.Timestamp('2015-04-14 00:01:01')
np.timedelta64(z-y)
>>>numpy.timedelta64(1000000,'us')

Correct

w = np.datetime64(y)
x = np.datetime64(z)
np.timedelta64(x-w)
>>>numpy.timedelta64(61000000,'us')

Correct

y = np.datetime64('2015-04-14 00:00:00')
z = np.datetime64('2015-04-14 00:01:01')
np.timedelta64(z-y)
>>>numpy.timedelta64(61,'s')

Does anyone have an explanation?

Upvotes: 1

Views: 230

Answers (1)

um8ra
um8ra

Reputation: 195

Seems to be an issue with Pandas 0.15.2. Upgrading to 0.16.0 solves the issue.

Upvotes: 1

Related Questions