code: def split_pandas_data_with_ratios(
      data, ratios, seed=42, shuffle=False
  ):
      """Helper function to split pandas DataFrame with given ratios
  
      .. note::
  
          Implementation referenced from `this source <https://stackoverflow.com/questions/38250710/how-to-split-data-into-3-sets-train-validation-and-test>`_.
  
      Args:
          data (pandas.DataFrame): Pandas data frame to be split.
          ratios (list of floats): list of ratios for split. The ratios have to sum to 1.
          seed (int): random seed.
          shuffle (bool): whether data will be shuffled when being split.
  
      Returns:
          list: List of pd.DataFrame split by the given specifications.
      """
      if math.fsum(ratios) != 1.0:
          raise ValueError("The ratios have to sum to 1")
  
      split_index = np.cumsum(ratios).tolist()[:-1]
  
      if shuffle:
          data = data.sample(frac=1, random_state=seed)
  
      splits = np.split(
          data, [round(x * len(data)) for x in split_index]
      )
  
      # Add split index (this makes splitting by group more efficient).
      for i in range(len(ratios)):
          splits[i]["split_index"] = i
  
      return splits
  
file_path: recommenders/recommenders/datasets/split_utils.py
imports: import numpy
  import math
  import logging
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL
label_desc: Use image node_id 5 for calling a global function with example usage: split_pandas_data_with_ratios(data, ratios, seed, shuffle) and returns: splits