def pd_train_eval_split(df, eval_split=0.0, seed=None, reset_index=False):
  """Splits pandas dataframe into train/eval sets.

  Uses pandas DataFrame.sample to create the split.

  Args:
    df: Dataframe of examples to be split.
    eval_split: Float in range (0, 1), fraction of dataset to split out as eval
      set.
    seed: Optional, for reproducibility of eval split.
    reset_index: If False (default) then retains original df indexing in
      returned train/eval dataframes, if True then resets index of both.

  Returns:
    Tuple (train dataset, num train examples, eval dataset, num eval examples).

    Sizes of returned dataframes aren't necessary but included to match the
    corresponding tensorflow function.
  """
  eval_df = df.sample(frac=eval_split, random_state=seed, replace=False)
  eval_idx = eval_df.index
  train_df = df.drop(index=eval_idx)
  num_eval_examples, num_train_examples = len(eval_df), len(train_df)
  if reset_index:
    train_df.reset_index(drop=True, inplace=True)
    eval_df.reset_index(drop=True, inplace=True)
  return train_df, num_train_examples, eval_df, num_eval_examples