

def test_first_last_valid(self):
    ts = self.ts.copy()
    ts[:5] = np.NaN
    index = ts.first_valid_index()
    self.assertEqual(index, ts.index[5])
    ts[(- 5):] = np.NaN
    index = ts.last_valid_index()
    self.assertEqual(index, ts.index[(- 6)])
    ts[:] = np.nan
    self.assertIsNone(ts.last_valid_index())
    self.assertIsNone(ts.first_valid_index())
    ser = Series([], index=[])
    self.assertIsNone(ser.last_valid_index())
    self.assertIsNone(ser.first_valid_index())
    empty = Series()
    self.assertIsNone(empty.last_valid_index())
    self.assertIsNone(empty.first_valid_index())

dataset/ETHPy150Open pydata/pandas/pandas/tests/series/test_timeseries.py TestSeriesTimeSeries.test_first_last_valid/original