code: def filter_k_core(
      data, core_num=0, col_user="userID", col_item="itemID"
  ):
      """Filter rating dataframe for minimum number of users and items by
      repeatedly applying min_rating_filter until the condition is satisfied.
  
      """
      num_users, num_items = len(data[col_user].unique()), len(
          data[col_item].unique()
      )
      logger.info(
          "Original: %d users and %d items", num_users, num_items
      )
      df_inp = data.copy()
  
      if core_num > 0:
          while True:
              df_inp = min_rating_filter_pandas(
                  df_inp, min_rating=core_num, filter_by="item"
              )
              df_inp = min_rating_filter_pandas(
                  df_inp, min_rating=core_num, filter_by="user"
              )
              count_u = df_inp.groupby(col_user)[col_item].count()
              count_i = df_inp.groupby(col_item)[col_user].count()
              if (
                  len(count_i[count_i < core_num]) == 0
                  and len(count_u[count_u < core_num]) == 0
              ):
                  break
      df_inp = df_inp.sort_values(by=[col_user])
      num_users = len(df_inp[col_user].unique())
      num_items = len(df_inp[col_item].unique())
      logger.info("Final: %d users and %d items", num_users, num_items)
  
      return df_inp
  
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 6 for calling a global function with example usage: filter_k_core(data, core_num, col_user, col_item) and returns: df_inp