code: def randc(nlevels=5, shape=(5, 5), missingness="mcar", thr=0.2):
      """Return randomly generated dataset with uniformly distributed categorical data (alphabetic character)
  
      Parameters
      ----------
      nlevels: int
          Specify the number of different categories in the dataset
      shape: tuple(optional)
          Size of the randomly generated data
      missingness: string in ('mcar', 'mar', 'mnar')
          Type of missingness you want in your dataset
      thr: float between [0,1]
          Percentage of missing data in generated data
  
      Returns
      -------
      numpy.ndarray
      """
      if shape[0] * shape[1] < nlevels:
          raise error.BadInputError(
              "nlevel exceeds the size of desired dataset. Please decrease the nlevel or increase the shape"
          )
  
      length = len(string.ascii_lowercase)
      n_fold = int(math.floor(math.log(nlevels, length)))
      cat_pool = list(string.ascii_lowercase)
  
      # when nlevel > 26, the alphabetical character is used up, need to generate extra strings as categorical data
      if n_fold > 0:
          for i in range(2, n_fold + 2):
              pool_candidate = list(
                  itertools.product(string.ascii_lowercase, repeat=i)
              )
              cat_pool.extend(["".join(w) for w in pool_candidate])
              if len(cat_pool) > nlevels:
                  break
  
      cat = random.sample(cat_pool, nlevels)
      data = np.random.choice(cat, shape, replace=True)
  
      # make sure the data frame has nlevel different categories
      while len(np.unique(data)) != nlevels:
          data = np.random.choice(cat, shape, replace=True)
  
      corruptor = Corruptor(data, thr=thr, dtype=np.str)
      raw_data = getattr(corruptor, missingness)()
      return raw_data
  
file_path: impyute/impyute/dataset/base.py
imports: import itertools
  import math
  import random
  import string
  import numpy
  from impyute.dataset.corrupt import Corruptor
  from impyute.ops import error
label_desc: Use image node_id 3 for calling a global function with example usage: randc(nlevels, shape, missingness, thr) and returns: raw_data