def transform(self, X, y=None, override_return_df=False):
if self.handle_missing == '<STR_LIT:error>':<EOL><INDENT>if X[self.cols].isnull().any().bool():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>if self._dim is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>X = util.convert_input(X)<EOL>if X.shape[<NUM_LIT:1>] != self._dim:<EOL><INDENT>raise ValueError('<STR_LIT>' % (X.shape[<NUM_LIT:1>], self._dim,))<EOL><DEDENT>if y is not None:<EOL><INDENT>y = util.convert_input_vector(y, X.index).astype(float)<EOL>if X.shape[<NUM_LIT:0>] != y.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError("<STR_LIT>" + str(X.shape[<NUM_LIT:0>]) + "<STR_LIT>" + str(y.shape[<NUM_LIT:0>]) + "<STR_LIT:.>")<EOL><DEDENT><DEDENT>if not self.cols:<EOL><INDENT>return X<EOL><DEDENT>X = X.copy(deep=True)<EOL>X = self.ordinal_encoder.transform(X)<EOL>if self.handle_unknown == '<STR_LIT:error>':<EOL><INDENT>if X[self.cols].isin([-<NUM_LIT:1>]).any().any():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>X = self._score(X, y)<EOL>if self.drop_invariant:<EOL><INDENT>for col in self.drop_cols:<EOL><INDENT>X.drop(col, <NUM_LIT:1>, inplace=True)<EOL><DEDENT><DEDENT>if self.return_df or override_return_df:<EOL><INDENT>return X<EOL><DEDENT>else:<EOL><INDENT>return X.values<EOL><DEDENT>
Perform the transformation to new categorical data. When the data are used for model training,
        it is important to also pass the target in order to apply leave one out.

        Parameters
        ----------

        X : array-like, shape = [n_samples, n_features]
        y : array-like, shape = [n_samples] when transform by leave one out
            None, when transform without target information (such as transform test set)



        Returns
        -------

        p : array, shape = [n_samples, n_numeric + N]
            Transformed values with encoding applied.