train_test_split : stratify can not be recognized? I'm trying to set stratify = True, but somehow jupyter notebook says 'name 'y' is not defined'

X_train, X_test, y_train, y_test = train_test_split(
    loan.drop('Loan_Status', axis=1), 
    loan['Loan_Status'], test_size=0.2, random_state=0, stratify=y)


Can anyone tell me what is the proper way to do it?

I'm using Scikit-learn v0.19.1 and have tried to set stratify = True / y / 2 but none of them worked.
You need to pass an array containing the class-labels (or whatever the criterion for stratifying is) as an argument to stratify. 

In your case, the answer is probably loan['Loan_Status'].values.