def test_date_select(): df = pd.DataFrame({'date':pd.to_datetime( [date(2013,m,1) for m in range(1,13)])}) assert np.array_equal(data.date_select(df, 'date', date(2013,4,1), 'all').values, df.values[0:3]) # test it on a pandas timestamp column too df['date'] = pd.to_datetime(df['date']) assert np.array_equal(data.date_select(df, 'date', date(2013,4,1), 'all').values, df.values[0:3])
def test_date_select(): df = pd.DataFrame( {'date': pd.to_datetime([date(2013, m, 1) for m in range(1, 13)])}) assert np.array_equal( data.date_select(df, 'date', date(2013, 4, 1), 'all').values, df.values[0:3]) # test it on a pandas timestamp column too df['date'] = pd.to_datetime(df['date']) assert np.array_equal( data.date_select(df, 'date', date(2013, 4, 1), 'all').values, df.values[0:3])
def get_data(self, date, delta): df = self.inputs[0].get_result() df = data.date_select(df, self.date_column, date, delta) df = data.date_censor(df.copy(), self.censor_columns, date) return df