def split_dataframe()

in recommended-item-search/data_preparation.py [0:0]


def split_dataframe(dataframe, holdout_fraction=0.1):
  """Splits a DataFrame into training and test sets.
  Args:
    dataframe: a dataframe.
    holdout_fraction: fraction of dataframe rows to use in the test set.
  Returns:
    train: dataframe for training
    test: dataframe for testing
  """
  test = dataframe.sample(frac=holdout_fraction, replace=False)
  train = dataframe[~dataframe.index.isin(test.index)]
  return train, test