Пример #1
0
    def test_fast_get_loc_ffilled(self):
        dts = pd.to_datetime([
            '2014-01-02',
            '2014-01-03',
            # Skip 2014-01-04
            '2014-01-05',
            '2014-01-06',
        ])

        for dt in pd.date_range('2014-01-02', '2014-01-08'):
            result = zp_fixtures.fast_get_loc_ffilled(dts.values, dt.asm8)
            expected = dts.get_loc(dt, method='ffill')
            assert_equal(result, expected)

        with self.assertRaises(KeyError):
            dts.get_loc(pd.Timestamp('2014-01-01'), method='ffill')

        with self.assertRaises(KeyError):
            zp_fixtures.fast_get_loc_ffilled(dts, pd.Timestamp('2014-01-01'))
Пример #2
0
    def test_fast_get_loc_ffilled(self):
        dts = pd.to_datetime([
            "2014-01-02",
            "2014-01-03",
            # Skip 2014-01-04
            "2014-01-05",
            "2014-01-06",
        ])

        for dt in pd.date_range("2014-01-02", "2014-01-08"):
            result = zp_fixtures.fast_get_loc_ffilled(dts.values, dt.asm8)
            expected = dts.get_loc(dt, method="ffill")
            assert_equal(result, expected)

        with self.assertRaises(KeyError):
            dts.get_loc(pd.Timestamp("2014-01-01"), method="ffill")

        with self.assertRaises(KeyError):
            zp_fixtures.fast_get_loc_ffilled(dts, pd.Timestamp("2014-01-01"))