'Coerce self into a pandas categorical.
This is only defined on 1D arrays, since that\'s all pandas supports.'

def as_categorical(self, name=None):

    if (len(self.shape) > 1):
        raise ValueError("Can't    convert    a    2D    array    to    a    categorical.")
    with ignore_pandas_nan_categorical_warning():
        return pd.Categorical.from_codes(self.as_int_array(), self.categories.copy(), ordered=False, name=name)
