k fold cross validation i want to use KFold from mode_selection instead of cross_validation ut it didn't work for the pobject Kfold

 from sklearn.model_selection import KFold
    import xgboost as xgb
    # Some useful parameters which will come in handy later on
    ntrain = X_train.shape[0]
    ntest = X_test.shape[0]
    SEED = 123 # for reproducibility
    NFOLDS = 10 # set folds for out-of-fold prediction
    kf = KFold(shuffle=False, n_splits= NFOLDS, random_state=SEED)
    def get_oof(clf, x_train, y_train, x_test):
        oof_train = np.zeros((ntrain,))
        oof_test = np.zeros((ntest,))
        oof_test_skf = np.empty((NFOLDS, ntest))

        for i, (train_index, test_index) in enumerate(kf):
            x_tr = x_train[train_index]
            y_tr = y_train[train_index]
            x_te = x_train[test_index]

            clf.train(x_tr, y_tr)

            oof_train[test_index] = clf.predict(x_te)
            oof_test_skf[i, :] = clf.predict(x_test)

        oof_test[:] = oof_test_skf.mean(axis=0)
        return oof_train.reshape(-1, 1), oof_test.reshape(-1, 1)
    xgb_oof_train, xgb_oof_test = get_oof(xgb,x_train, y_train, x_test)


i got this error TypeError: 'KFold' object is not iterable
Try to use the split method as enumerate argument, instead of kf (e.g.:for i, (train_index, test_index) in enumerate(kf.split(X)): 

Hope it helps!