code: def apply_train(self, df:DataFrame):
          "Transform `self.cat_names` columns in categorical."
          self.categories = {}
          for n in self.cat_names:
              df.loc[:,n] = df.loc[:,n].astype('category').cat.as_ordered()
              self.categories[n] = df[n].cat.categorief apply_train(self, df:DataFrame):
          "Transform `self.cat_names` columns in categorical."
          self.categories = {}
          for n in self.cat_names:
              df.loc[:,n] = df.loc[:,n].astype('category').cat.as_ordered()
              self.categories[n] = df[n].cat.categories
docs: Transform `self.cat_names` columns in categorical.