def not_new_items_filter(training, testing):

    test_users = testing.user.unique()
    for u in test_users:
        training_items_of_u =  training[training.user == u].item.unique()
        testing = testing[(testing.user != u) | ((testing.user == u) & ~testing.item.isin(training_items_of_u))]
    return testing
Given two data frames, it filters from the testing frame all the non-new items.
dataset/ETHPy150Open grafos-ml/test.fm/src/testfm/splitter/split_utils.py/not_new_items_filter