def cat_group(dfx, kpix, n_group=10):
    """
    Category Reduction for Categorical Variables

    Args
    ----

    dfx : dataframe
        The inputs data dataframe.

    kpix : string
        The column of the feature.

    n_group : int, optional (default = 10)
        The number of top category values to be remained, other category values will be put into "Other".

    Returns
    -------
    The transformed categorical feature value list.
    """
    if dfx[kpix].nunique() > n_group:
        top = dfx[kpix].isin(dfx[kpix].value_counts().index[:n_group])
        dfx.loc[~top, kpix] = 'Other'
        return dfx[kpix].values
    else:
        return dfx[kpix].values
