def to_category(train, cat=None):
    if (cat is None):
        cat = [col for col in train.columns if (train[col].dtype == 'object')]
    for c in cat:
        (train[c], uniques) = pd.factorize(train[c])
        maxvalue_dict[c] = (train[c].max() + 1)
    return train
def to_category(train, cat=None):
    if (cat is None):
        cat = [col for col in train.columns if (train[col].dtype == 'object')]
    for c in cat:
        (train[c], uniques) = pd.factorize(train[c])
        maxvalue_dict[c] = (train[c].max() + 1)
    return train