def convert_obj_columns_to_cat(df, exclude_cols):
    """
    Convert the datatype of object columns to category columns.

    :param df: Dataframe of the data
    :type  df: pandas.core.frame.DataFrame
    :param exclude_cols: set of columns to exclude from conversion
    :type  exclude_cols: set
    :returns: dataframe
    :rtype:   pandas.core.frame.DataFrame
    """

    column_list = df.select_dtypes(include=['object']).columns
    column_list = [col for col in column_list if col not in exclude_cols]
    for col in column_list:
        print("converting", col.ljust(30),
              "size: ", round(df[col].memory_usage(deep=True)*1e-6, 2), end="\t")
        df[col] = df[col].astype("category")
        print("->\t", round(df[col].memory_usage(deep=True)*1e-6, 2))
    return df