text_plain_output_1.png
import cudf

train = cudf.read_csv('../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv')
train['customer_id'] = train['customer_id'].str[-16:].str.hex_to_int().astype('int64')
train['article_id'] = train.article_id.astype('int32')
train.t_dat = cudf.to_datetime(train.t_dat)
train = train[['t_dat', 'customer_id', 'article_id']]
train.to_parquet('train.pqt', index=False)

tmp = train.groupby('customer_id').t_dat.max().reset_index()
tmp.columns = ['customer_id', 'max_dat']
train = train.merge(tmp, on=['customer_id'], how='left')
train['diff_dat'] = (train.max_dat - train.t_dat).dt.days
train = train.loc[train['diff_dat'] <= 6]
print('Train shape:', train.shape)