<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def transform(self, X):
 """Encode categorical columns into sparse matrix with one-hot-encoding. Args: X (pandas.DataFrame):
 categorical columns to encode Returns: X_new (scipy.sparse.coo_matrix):
 sparse matrix encoding categorical variables into dummy variables """


        for i, col in enumerate(X.columns):
            X_col = self._transform_col(X[col], i)
            if X_col is not None:
                if i == 0:
                    X_new = X_col
                else:
                    X_new = sparse.hstack((X_new, X_col))

            logger.debug('{} --> {} features'.format(
                col, self.label_encoder.label_maxes[i])
            )

        return X_new