def transform(self, X, 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 not self.cols:<EOL><INDENT>return X<EOL><DEDENT>X_out = self.ordinal_encoder.transform(X)<EOL>if self.handle_unknown == '<STR_LIT:error>':<EOL><INDENT>if X_out[self.cols].isin([-<NUM_LIT:1>]).any().any():<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>X_out = self.basen_encode(X_out, cols=self.cols)<EOL>if self.drop_invariant:<EOL><INDENT>for col in self.drop_cols:<EOL><INDENT>X_out.drop(col, <NUM_LIT:1>, inplace=True)<EOL><DEDENT><DEDENT>if self.return_df or override_return_df:<EOL><INDENT>return X_out<EOL><DEDENT>else:<EOL><INDENT>return X_out.values<EOL><DEDENT>
Perform the transformation to new categorical data.

        Parameters
        ----------

        X : array-like, shape = [n_samples, n_features]

        Returns
        -------

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