

def test_asof(self):
    N = 50
    rng = date_range('1/1/1990', periods=N, freq='53s')
    ts = Series(np.random.randn(N), index=rng)
    mask[15:30] = np.nan
    dates = date_range('1/1/1990', periods=(N * 3), freq='25s')
    result = ts.asof(dates)
    self.assertTrue(notnull(result).all())
    lb = ts.index[14]
    ub = ts.index[30]
    result = ts.asof(list(dates))
    self.assertTrue(notnull(result).all())
    lb = ts.index[14]
    ub = ts.index[30]
    mask = ((result.index >= lb) & (result.index < ub))
    rs = result[mask]
    self.assertTrue((rs == ts[lb]).all())
    val = result[result.index[(result.index >= ub)][0]]
    self.assertEqual(ts[ub], val)
    self.ts[5:10] = np.NaN
    self.ts[15:20] = np.NaN
    val1 = self.ts.asof(self.ts.index[7])
    val2 = self.ts.asof(self.ts.index[19])
    self.assertEqual(val1, self.ts[4])
    self.assertEqual(val2, self.ts[14])
    val1 = self.ts.asof(str(self.ts.index[7]))
    self.assertEqual(val1, self.ts[4])
    self.assertEqual(self.ts.asof(self.ts.index[3]), self.ts[3])
    d = (self.ts.index[0] - datetools.bday)
    self.assertTrue(np.isnan(self.ts.asof(d)))

dataset/ETHPy150Open pydata/pandas/pandas/tests/series/test_timeseries.py TestSeriesTimeSeries.test_asof/VarMisuse@47/61 `ts`->`mask`