Skip to content

Commit 486ad67

Browse files
winklerandjreback
authored andcommitted
TST: add test case for multiple consecutive NaTs in PeriodIndex
1 parent c8814fb commit 486ad67

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

pandas/tests/test_resample.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,16 +2878,22 @@ def test_upsampling_ohlc(self, freq, period_mult, kind):
28782878
result = s.resample(freq, kind=kind).ohlc()
28792879
assert_frame_equal(result, expected)
28802880

2881+
@pytest.mark.parametrize('periods, values',
2882+
[([pd.NaT, '1970-01-01 00:00:00', pd.NaT,
2883+
'1970-01-01 00:00:02', '1970-01-01 00:00:03'],
2884+
[2, 3, 5, 7, 11]),
2885+
([pd.NaT, pd.NaT, '1970-01-01 00:00:00', pd.NaT,
2886+
pd.NaT, pd.NaT, '1970-01-01 00:00:02',
2887+
'1970-01-01 00:00:03', pd.NaT, pd.NaT],
2888+
[1, 2, 3, 5, 6, 8, 7, 11, 12, 13])])
28812889
@pytest.mark.parametrize('freq, expected_values',
28822890
[('1s', [3, np.NaN, 7, 11]),
28832891
('2s', [3, int((7 + 11) / 2)]),
28842892
('3s', [int((3 + 7) / 2), 11])])
2885-
def test_resample_with_nat(self, freq, expected_values):
2893+
def test_resample_with_nat(self, periods, values, freq, expected_values):
28862894
# GH 13224
2887-
index = PeriodIndex([pd.NaT, '1970-01-01 00:00:00', pd.NaT,
2888-
'1970-01-01 00:00:02', '1970-01-01 00:00:03'],
2889-
freq='S')
2890-
frame = DataFrame([2, 3, 5, 7, 11], index=index)
2895+
index = PeriodIndex(periods, freq='S')
2896+
frame = DataFrame(values, index=index)
28912897

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

0 commit comments

Comments
 (0)