BUG: ufunc with PeriodIndex may raise IncompatibleFrequency by sinhrks · Pull Request #13980 · pandas-dev/pandas (original) (raw)
- tests added / passed
- passes
git diff upstream/master | flake8 --diff
- whatsnew entry
PeriodIndex
supportds addition / subtraction with integer.
# OK
pi = pd.PeriodIndex(['2011-01'], freq='M')
pi + 1
# PeriodIndex(['2011-02'], dtype='int64', freq='M')
pi - 1
# PeriodIndex(['2010-12'], dtype='int64', freq='M')
but raises if op is performed via ufunc.
# NG
np.add(pi, 1)
# pandas._period.IncompatibleFrequency: Input has different freq from PeriodIndex(freq=M)
np.subtract(pi, 1)
# pandas._period.IncompatibleFrequency: Input has different freq from PeriodIndex(freq=M)