def get_mushroom_data():

    df = pd.read_csv('source_data/mushrooms/agaricus-lepiota.csv')
    X = df.reindex(columns=[x for x in df.columns.values if x != 'class'])
    y = df.reindex(columns=['class'])
    y = preprocessing.LabelEncoder().fit_transform(y.values.reshape(-1, ))

    # this data is truly categorical, with no known concept of ordering
    mapping = None

    return X, y, mapping
Load the mushroom dataset, split it into X and y, and then call the label encoder to get an integer y column.
dataset/ETHPy150Open wdm0006/categorical_encoding/source_data/loaders.py/get_mushroom_data