code: def unique(self):
          unique_codes = unique1d(self.codes)
          cat = self.copy()
          cat._codes = unique_codes
          take_codes = unique_codes[unique_codes != -1]
          if self.ordered:
              take_codes = np.sort(take_codes)
          return cat.set_categories(cat.categories.take(take_codes))