Skip to content

Commit

Permalink
TST: add test case for multiple consecutive NaTs in PeriodIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
winklerand committed May 13, 2017
1 parent f12150b commit 1cad7fa
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pandas/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,16 +2830,22 @@ def test_upsampling_ohlc(self, freq, period_mult, kind):
result = s.resample(freq, kind=kind).ohlc()
assert_frame_equal(result, expected)

@pytest.mark.parametrize('periods, values',
[([pd.NaT, '1970-01-01 00:00:00', pd.NaT,
'1970-01-01 00:00:02', '1970-01-01 00:00:03'],
[2, 3, 5, 7, 11]),
([pd.NaT, pd.NaT, '1970-01-01 00:00:00', pd.NaT,
pd.NaT, pd.NaT, '1970-01-01 00:00:02',
'1970-01-01 00:00:03', pd.NaT, pd.NaT],
[1, 2, 3, 5, 6, 8, 7, 11, 12, 13])])
@pytest.mark.parametrize('freq, expected_values',
[('1s', [3, np.NaN, 7, 11]),
('2s', [3, int((7 + 11) / 2)]),
('3s', [int((3 + 7) / 2), 11])])
def test_resample_with_nat(self, freq, expected_values):
def test_resample_with_nat(self, periods, values, freq, expected_values):
# GH 13224
index = PeriodIndex([pd.NaT, '1970-01-01 00:00:00', pd.NaT,
'1970-01-01 00:00:02', '1970-01-01 00:00:03'],
freq='S')
frame = DataFrame([2, 3, 5, 7, 11], index=index)
index = PeriodIndex(periods, freq='S')
frame = DataFrame(values, index=index)

expected_index = period_range('1970-01-01 00:00:00',
periods=len(expected_values), freq=freq)
Expand Down

0 comments on commit 1cad7fa

Please sign in to comment.