code: def partition_rows(data, partitions, *, rng_spec=None):
      """
      Partition a frame of ratings or other datainto train-test partitions.  This function does not
      care what kind of data is in `data`, so long as it is a Pandas DataFrame (or equivalent).
  
      Args:
          data(pandas.DataFrame):
              Ratings or other data you wish to partition.
          partitions(int):
              The number of partitions to produce.
          rng_spec:
              The random number generator or seed (see :py:func:`seedbank.numpy_rng`).
  
      Returns:
          iterator: an iterator of train-test pairs
      """
  
      confirm_unique_index(data)
      _logger.info(
          "partitioning %d ratings into %d partitions",
          len(data),
          partitions,
      )
  
      # create an array of indexes
      rows = np.arange(len(data))
      # shuffle the indices & split into partitions
      rng = numpy_rng(rng_spec)
      rng.shuffle(rows)
      test_sets = np.array_split(rows, partitions)
  
      # convert each partition into a split
      for i, ts in enumerate(test_sets):
          test = data.iloc[ts, :]
          trains = test_sets[:i] + test_sets[(i + 1) :]
          train_idx = np.concatenate(trains)
          train = data.iloc[train_idx, :]
          yield TTPair(train, test)
  
imports: from collections import namedtuple
  import logging
  from abc import ABC, abstractmethod
  import numpy
  import pandas
  from seedbank import numpy_rng
label_desc: Use image node_id 1 for calling a global function with example usage: partition_rows(data, partitions) without return types