text_plain_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('../input/act_train.csv', parse_dates=['date'])
test = pd.read_csv('../input/act_test.csv', parse_dates=['date'])
ppl = pd.read_csv('../input/people.csv', parse_dates=['date'])
df_train = pd.merge(train, ppl, on='people_id')
df_test = pd.merge(test, ppl, on='people_id')
del train, test, ppl

plus = sum(df_train.loc[:, 'outcome'] == 0)
minus = sum(df_train.loc[:, 'outcome'] == 1)

def data_cleanser(data, is_train):
    def adjust_dates(dates, diff):
        return dates - diff
    if is_train:
        df_dates = data['date_x']
        diff = df_dates.max() - df_dates.min()
        diff2 = df_dates.max() - pd.Timestamp(pd.datetime.now().date())
        diffdays = diff + diff2
        data['adj_date'] = adjust_dates(data['date_x'], diffdays)
    return data.drop(['date_x'], axis=1)

data_cleanser(df_train, True).head()