8000 BUG: Fix PeriodIndex +/- TimedeltaIndex by jbrockmendel · Pull Request #23031 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix PeriodIndex +/- TimedeltaIndex #23031

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

Merged
merged 14 commits into from
Oct 15, 2018
Merged
Prev Previous commit
Next Next commit
add tests for subtracting offset scalar
  • Loading branch information
jbrockmendel committed Oct 9, 2018
commit 0573f3f2e18fcf92c101725fe7b0062bcf8fef8a
17 changes: 17 additions & 0 deletions pandas/tests/ari 8000 thmetic/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,15 @@ def test_pi_add_timedeltalike_minute_gt1(self, three_days):
result = other + rng
tm.assert_index_equal(result, expected)

# subtraction
expected = pd.PeriodIndex(['2014-04-28', '2014-04-30', '2014-05-02'],
freq='2D')
result = rng - other
tm.assert_index_equal(result, expected)

with pytest.raises(TypeError):
other - rng

@pytest.mark.parametrize('freqstr', ['5ns', '5us', '5ms',
'5s', '5T', '5h', '5d'])
def test_pi_add_timedeltalike_tick_gt1(self, three_days, freqstr):
Expand All @@ -639,6 +648,14 @@ def test_pi_add_timedeltalike_tick_gt1(self, three_days, freqstr):
result = other + rng
tm.assert_index_equal(result, expected)

# subtraction
expected = pd.period_range(rng[0] - other, periods=6, freq=freqstr)
result = rng - other
tm.assert_index_equal(result, expected)

with pytest.raises(TypeError):
other - rng

def test_pi_add_iadd_timedeltalike_daily(self, three_days):
# Tick
other = three_days
Expand Down
0