code: def transform_categorical_col(self, col_vals, col_name):
      if self.get("keep_cat_features", False) == True:
          return_vals = self.get("label_encoders")[col_name].transform(
              col_vals
          )
          result = {col_name: return_vals}
  
          result = pd.DataFrame(result)
          # result[col_name] = pd.to_numeric(result[col_name], downcast='integer')
  
          return result
  
      else:
          num_trained_cols = 0
          min_transformed_idx = None
          max_transformed_idx = None
          len_col_name = len(col_name)
          encoded_col_names = []
  
          for trained_feature, col_idx in self.vocabulary_.items():
              if trained_feature[:len_col_name] == col_name:
                  encoded_col_names.append([trained_feature, col_idx])
                  num_trained_cols += 1
                  if min_transformed_idx is None:
                      min_transformed_idx = col_idx
                      max_transformed_idx = col_idx
                  elif col_idx > max_transformed_idx:
                      max_transformed_idx = col_idx
                  elif col_idx < min_transformed_idx:
                      min_transformed_idx = col_idx
  
          encoded_col_names = sorted(
              encoded_col_names, key=lambda tup: tup[1]
          )
          encoded_col_names = [tup[0] for tup in encoded_col_names]
  
          result = sp.lil_matrix((len(col_vals), num_trained_cols))
  
          if num_trained_cols == 0:
              df_result = pd.DataFrame(
                  result.toarray(), columns=encoded_col_names
              )
              return df_result
  
          if num_trained_cols != (
              max_transformed_idx - min_transformed_idx + 1
          ):
              print(
                  "We have somehow ended up with categorical column behavior we were not expecting"
              )
              raise (ValueError)
  
          for row_idx, val in enumerate(col_vals):
              if not isinstance(val, str):
                  if isinstance(val, numbers.Number) or val is None:
                      val = str(val)
                  else:
                      val = val.encode("utf-8").decode("utf-8")
  
              feature_name = col_name + self.separator + val
              if feature_name in self.vocabulary_:
                  col_idx = self.vocabulary_[feature_name]
                  col_idx = col_idx - min_transformed_idx
  
                  result[row_idx, col_idx] = 1
  
          df_result = pd.DataFrame(
              result.toarray(), columns=encoded_col_names
          )
          return df_result
  
imports: from array import array
  import numbers
  from operator import itemgetter
  import numpy
  import pandas
  import scipy.sparse
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.externals import six
  from auto_ml.utils import CustomLabelEncoder
label_desc: Use image node_id 5 for calling the DataFrameVectorizer obj's underlying member method code with example usage: obj.transform_categorical_col(col_vals, col_name) and returns: result, df_result, df_result