Skip to content

Commit 1cad7fa

Browse files
committed
TST: add test case for multiple consecutive NaTs in PeriodIndex
1 parent f12150b commit 1cad7fa

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

pandas/tests/test_resample.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -2830,16 +2830,22 @@ def test_upsampling_ohlc(self, freq, period_mult, kind):
28302830
result = s.resample(freq, kind=kind).ohlc()
28312831
assert_frame_equal(result, expected)
28322832

2833+
@pytest.mark.parametrize('periods, values',
2834+
[([pd.NaT, '1970-01-01 00:00:00', pd.NaT,
2835+
'1970-01-01 00:00:02', '1970-01-01 00:00:03'],
2836+
[2, 3, 5, 7, 11]),
2837+
([pd.NaT, pd.NaT, '1970-01-01 00:00:00', pd.NaT,
2838+
pd.NaT, pd.NaT, '1970-01-01 00:00:02',
2839+
'1970-01-01 00:00:03', pd.NaT, pd.NaT],
2840+
[1, 2, 3, 5, 6, 8, 7, 11, 12, 13])])
28332841
@pytest.mark.parametrize('freq, expected_values',
28342842
[('1s', [3, np.NaN, 7, 11]),
28352843
('2s', [3, int((7 + 11) / 2)]),
28362844
('3s', [int((3 + 7) / 2), 11])])
2837-
def test_resample_with_nat(self, freq, expected_values):
2845+
def test_resample_with_nat(self, periods, values, freq, expected_values):
28382846
# GH 13224
2839-
index = PeriodIndex([pd.NaT, '1970-01-01 00:00:00', pd.NaT,
2840-
'1970-01-01 00:00:02', '1970-01-01 00:00:03'],
2841-
freq='S')
2842-
frame = DataFrame([2, 3, 5, 7, 11], index=index)
2847+
index = PeriodIndex(periods, freq='S')
2848+
frame = DataFrame(values, index=index)
28432849

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

0 commit comments

Comments
 (0)