code: def index_by(self, field):
          
          values = self[field].unique()
          results = {}
          for value in values:
              results[value] = self.model_class(**self[self[field] == value].iloc[0])
          return results
docs: Returns a dict with a key for each value of `field` and the first record with that value as value.
          :param field: Name of the field to index by.
          :type field: string.