def gen_cat(df):
    """
    Generate a data frame only including catgorical variables.

    Parameters
    ----------
    df : pandas data frame
        whole data frame.

    Returns
    -------
    df_new: pandas data frame
        new data frame only including categorical variables.

    """
    feat_cat = ['derived_msa_md', 'county_code',
                'conforming_loan_limit',
                'derived_race', 'derived_sex',
                'hoepa_status',
                'interest_only_payment',
                'balloon_payment', 'occupancy_type',
                'total_units', 'applicant_race_1', 'applicant_sex',
                'applicant_age_above_62', 'co_applicant_age_above_62',
                'derived_loan_product_type',
                'lien_status', 'open_end_line_of_credit',
                'business_or_commercial_purpose'
                ]
    df_new = df[feat_cat]
    return df_new