I have written function:
def inters(obs_test, train_tbl): intersect_n = 0 for i in train_tbl: intersect_n += ((obs_test * i).sum() / train_tbl