code: def python_stratified_split(
      data,
      ratio=0.75,
      min_rating=1,
      filter_by="user",
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      seed=42,
  ):
      """Pandas stratified splitter.
  
      For each user / item, the split function takes proportions of ratings which is
      specified by the split ratio(s). The split is stratified.
  
      Args:
          data (pandas.DataFrame): Pandas DataFrame to be split.
          ratio (float or list): Ratio for splitting data. If it is a single float number
              it splits data into two halves and the ratio argument indicates the ratio of
              training data set; if it is a list of float numbers, the splitter splits
              data into several portions corresponding to the split ratios. If a list is
              provided and the ratios are not summed to 1, they will be normalized.
          seed (int): Seed.
          min_rating (int): minimum number of ratings for user or item.
          filter_by (str): either "user" or "item", depending on which of the two is to
              filter with min_rating.
          col_user (str): column name of user IDs.
          col_item (str): column name of item IDs.
  
      Returns:
          list: Splits of the input data as pandas.DataFrame.
      """
      return _do_stratification(
          data,
          ratio=ratio,
          min_rating=min_rating,
          filter_by=filter_by,
          col_user=col_user,
          col_item=col_item,
          is_random=True,
          seed=seed,
      )
  
file_path: recommenders/recommenders/datasets/python_splitters.py
imports: import numpy
  import pandas
  from sklearn.model_selection import train_test_split
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL, DEFAULT_TIMESTAMP_COL
  from recommenders.datasets.split_utils import process_split_ratio, min_rating_filter_pandas, split_pandas_data_with_ratios
label_desc: Use image node_id 4 for calling a global function with example usage: python_stratified_split(data, ratio, min_rating, filter_by, col_user, col_item, seed) and returns: _do_stratification