Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
@sinhrks
Copy link
Member

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
@sinhrks

This comment has been minimized.

Copy link
Member Author

commented Jul 13, 2014

Related to #5202.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.