text_plain_output_1.png
from sklearn import model_selection

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.read_csv('../input/adult-census-income/adult.csv')
df.income.value_counts()

from sklearn import model_selection
df['kfold'] = -1
df = df.sample(frac=1).reset_index(drop=True)
y = df.income.values
kf = model_selection.StratifiedKFold(n_splits=5)
for fold, (train_, valid_) in enumerate(kf.split(X=df, y=y)):
    df.loc[valid_, 'kfold'] = fold
df.to_csv('./adult_folds.csv', index=False)

df_fold = pd.read_csv('./adult_folds.csv')
df_train = df[df.kfold != 0].reset_index(drop=True)
df_train.income.isnull().sum()