class_docstr: DataFile class for NCF. Iterator to read data from a csv file.
  Data must be sorted by user. Includes utilities for loading user data from
  file, formatting it and returning a Pandas dataframe.
class_docstr_tok: ["DataFile","class","for","NCF",".","Iterator","to","read","data","from","a","csv","file",".","Data","must","be","sorted","by","user",".","Includes","utilities","for","loading","user","data","from","file",",","formatting","it","and","returning","a","Pandas","dataframe","."]
code: def _init_data(self):
      # Compile lists of unique users and items, assign IDs to users and items,
      # and ensure file is sorted by user (and batch index if test set)
      logger.info("Indexing {} ...".format(self.filename))
      with self:
          user_items = []
          self.item2id, self.user2id = OrderedDict(), OrderedDict()
          batch_index = 0
          for _ in self:
              item = self.row[self.col_item]
              user = self.row[self.col_user]
              test_batch = self.row[self.col_test_batch]
              if not self.end_of_file:
                  next_user = self.next_row[self.col_user]
                  next_test_batch = self.next_row[self.col_test_batch]
              if item not in self.items:
                  self.item2id[item] = len(self.item2id)
              user_items.append(item)
  
              if (next_user != user) or self.next_row is None:
                  if not self.end_of_file:
                      if next_user in self.users:
                          raise FileNotSortedException(
                              "File {} is not sorted by user".format(
                                  self.filename
                              )
                          )
                  self.user2id[user] = len(self.user2id)
              if self.col_test_batch:
                  if (
                      next_test_batch != test_batch
                  ) or self.next_row is None:
                      if not self.end_of_file:
                          if next_test_batch < batch_index:
                              raise FileNotSortedException(
                                  "File {} is not sorted by {}".format(
                                      self.filename, self.col_test_batch
                                  )
                              )
                      batch_index += 1
          self.batch_indices_range = range(0, batch_index)
          self.data_len = self.line_num
  
imports: import os
  from collections import OrderedDict
  import random
  import numpy
  import pandas
  import csv
  import logging
  from tqdm import tqdm
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL, DEFAULT_RATING_COL
label_desc: Use image node_id 11 for calling the DataFile obj's underlying member method code with example usage: obj._init_data() without return types