BUG: Period ops with np.timedelta64 cause unexpected result #7740

Closed
sinhrks opened this Issue Jul 12, 2014 · 1 comment

Comments

Projects
None yet
2 participants
Member

sinhrks commented Jul 12, 2014

Period + np.timedelta64 doesn't raise TypeError(NotImplemented) (like offsets does), and results in erratic internal representation.

import pandas as pd
import numpy as np

p = pd.Period('2011-01-01', freq='D')
p = p + np.timedelta64(2, 'h')
# This raises no error

print(p)
# TypeError: don't know how to convert scalar number to int

p.ordinal
#14977 hours

PeriodIndex + np.timedelta64 also doesn't raise TypeError(NotImplemented), and are added ignoring PeriodIndex.freq.

pidx = pd.period_range('2011-01-01', freq='D', periods=5)
pidx = pidx + np.timedelta64(2, 'h')
pidx
# <class 'pandas.tseries.period.PeriodIndex'>
# [2011-01-03, ..., 2011-01-07]
# Length: 5, Freq: D
Member

sinhrks commented Jul 13, 2014

Related to #5202.

jreback added this to the 0.15.0 milestone Jul 14, 2014

jreback closed this in #7966 Aug 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment