code: def as_categorical_frame(self, index, columns, name=None):
          
          if len(self.shape) != 2:
              raise ValueError(
                  "Can't convert a non-2D LabelArray into a DataFrame."
              )
  
          expected_shape = (len(index), len(columns))
          if expected_shape != self.shape:
              raise ValueError(
                  "Can't construct a DataFrame with provided indices:\n\n"
                  "LabelArray shape is {actual}, but index and columns imply "
                  "that shape should be {expected}.".format(
                      actual=self.shape,
                      expected=expected_shape,
                  )
              )
  
          return pd.Series(
              index=pd.MultiIndex.from_product([index, columns]),
              data=self.ravel().as_categorical(),
              name=name,
          ).unstack()
docs: Coerce self into a pandas DataFrame of Categoricals.