def add_gaps(df):
    """Add train-test gaps to dataframe."""
    for col in df.columns:
        if col.startswith("train_") and col.replace("train_", "test_") in df.columns:
            # gap = max(train - test, 0)
            gap_col = col.replace("train_", "gap_")
            df[gap_col] = df[col] - df[col.replace("train_", "test_")]
            df.loc[df[gap_col] < 0, gap_col] = 0
    return df