code: def _transform(self, X):
      dtype = self.dtype
      feature_names = self.feature_names_
      vocab = self.vocabulary_
  
      if isinstance(X, dict):
          indices = array("i")
          indptr = array("i", [0])
          values = []
  
          for f, val in X.items():
              if (
                  self.column_descriptions.get(f, False)
                  == "categorical"
              ):
                  if self.get("keep_cat_features", False) == False:
                      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")
                      f = f + self.separator + val
                      val = 1
                  else:
                      if val in bad_vals:
                          val = "_None"
                      val = self.get("label_encoders")[f].transform(
                          [val]
                      )
  
              if (
                  f in vocab
                  and val not in bad_vals
                  and (
                      self.get("keep_cat_features", False)
                      or not np.isnan(val)
                  )
              ):
                  indices.append(vocab[f])
                  # Convert the val to the correct dtype, then append to our values list
                  values.append(dtype(val))
  
          indptr.append(len(indices))
  
          if len(indptr) == 1:
              raise ValueError(
                  "The dictionary passed into DataFrameVectorizer is empty"
              )
  
          indices = np.frombuffer(indices, dtype=np.intc)
          indptr = np.frombuffer(indptr, dtype=np.intc)
          shape = (len(indptr) - 1, len(vocab))
  
          result_matrix = sp.csr_matrix(
              (values, indices, indptr), shape=shape, dtype=dtype
          )
  
          if self.sparse:
              result_matrix.sort_indices()
  
          return result_matrix
  
      else:
          for col in self.numerical_columns:
              if col not in X.columns:
                  X[col] = 0
          for col in self.categorical_columns:
              if col not in X.columns:
                  X[col] = 0
          for col in self.additional_numerical_cols:
              if col not in X.columns:
                  X[col] = 0
  
          X.fillna(0, inplace=True)
  
          for idx, col in enumerate(self.numerical_columns):
              if X[col].dtype not in self.numeric_col_types:
                  X[col] = X[col].astype(np.float32)
  
          # Running this in parallel can cause memory crashes if the dataset is too large.
          categorical_vals = list(
              map(
                  lambda col_name: self.transform_categorical_col(
                      col_vals=list(X[col_name]), col_name=col_name
                  ),
                  self.categorical_columns,
              )
          )
  
          X = X[self.numerical_columns]
          # X.drop(self.categorical_columns, inplace=True, axis=1)
          X.reset_index(drop=True, inplace=True)
          for result in categorical_vals:
              result.reset_index(drop=True, inplace=True)
              X[result.columns] = result
              del result
  
      if self.keep_cat_features == True:
          return X
      else:
          X = sp.csr_matrix(X.values)
          return X
  
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 4 for calling the DataFrameVectorizer obj's underlying member method code with example usage: obj._transform(X) and returns: result_matrix, X, X