def ordinal_encode(self, column, values=None, inplace=False):
column = _ensure_string_from_expression(column)<EOL>df = self if inplace else self.copy()<EOL>df_unfiltered = df.copy()<EOL>df_unfiltered.select_nothing(name=FILTER_SELECTION_NAME)<EOL>df_unfiltered._length_unfiltered = df._length_original<EOL>df_unfiltered.set_active_range(<NUM_LIT:0>, df._length_original)<EOL>found_values, codes = df_unfiltered.unique(column, return_inverse=True)<EOL>if values is None:<EOL><INDENT>values = found_values<EOL><DEDENT>else:<EOL><INDENT>translation = np.zeros(len(found_values), dtype=np.uint64)<EOL>missing_value = len(found_values)<EOL>for i, found_value in enumerate(found_values):<EOL><INDENT>try:<EOL><INDENT>found_value = found_value.decode('<STR_LIT:ascii>')<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if found_value not in values:  <EOL><INDENT>translation[i] = missing_value<EOL><DEDENT>else:<EOL><INDENT>translation[i] = values.index(found_value)<EOL><DEDENT><DEDENT>codes = translation[codes]<EOL>if missing_value in translation:<EOL><INDENT>codes = np.ma.masked_array(codes, codes==missing_value)<EOL><DEDENT><DEDENT>original_column = df.rename_column(column, '<STR_LIT>' + column, unique=True)<EOL>labels = [str(k) for k in values]<EOL>df.add_column(column, codes)<EOL>df._categories[column] = dict(labels=labels, N=len(values), values=values)<EOL>return df<EOL>
Encode column as ordinal values and mark it as categorical.

        The existing column is renamed to a hidden column and replaced by a numerical columns
        with values between [0, len(values)-1].