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","."]
docstr: Load data for a specified user or test batch
  
  Args:
      key (int): user or test batch index
      by_user (bool): load data by usr if True, else by test batch
  
  Returns:
      pandas.DataFrame
docstr_tok: ["Load","data","for","a","specified","user","or","test","batch","Args",":","key","(","int",")",":","user","or","test","batch","index","by_user","(","bool",")",":","load","data","by","usr","if","True",",","else","by","test","batch","Returns",":","pandas.DataFrame"]
code: def load_data(self, key, by_user=True):
      """Load data for a specified user or test batch
  
      Args:
          key (int): user or test batch index
          by_user (bool): load data by usr if True, else by test batch
  
      Returns:
          pandas.DataFrame
      """
      records = []
      key_col = self.col_user if by_user else self.col_test_batch
  
      # fast forward in file to user/test batch
      while (self.line_num == 0) or (self.row[key_col] != key):
          if self.end_of_file:
              raise MissingUserException(
                  "User {} not in file {}".format(key, self.filename)
              )
          next(self)
      # collect user/test batch data
      while self.row[key_col] == key:
          row = self.row
          if self.col_test_batch in row:
              del row[self.col_test_batch]
          records.append(row)
          if not self.end_of_file:
              next(self)
          else:
              break
      return pd.DataFrame.from_records(records)
  
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 12 for calling the DataFile obj's underlying member method code with example usage: obj.load_data(key, by_user) and returns: pd