code: def get_dim_index(js_dict, dim):
      
  
      try:
          dim_index = js_dict['dimension'][dim]['category']['index']
      except KeyError:
          dim_label = get_dim_label(js_dict, dim)
          dim_index = pd.DataFrame(list(zip([dim_label['id'][0]], [0])),
                                   index=[0],
                                   columns=['id', 'index'])
      else:
          if type(dim_index) is list:
              dim_index = pd.DataFrame(list(zip(dim_index,
                                                range(0, len(dim_index)))),
                                       index=dim_index, columns=['id', 'index'])
          else:
              dim_index = pd.DataFrame(list(zip(dim_index.keys(),
                                                dim_index.values())),
                                       index=dim_index.keys(),
                                       columns=['id', 'index'])
      dim_index = dim_index.sort_index(by='index')
      return dim_index
docs: Get index from a given dimension.
  
      Args:
        js_dict (dict): dictionary containing dataset data and metadata.
        dim (string): dimension name obtained from JSON file.
  
      Returns:
        dim_index (pandas.DataFrame): DataFrame with index-based dimension data.