code: def data_gen_custom(
      input_file, output_file, city_file, n, n_his, n_pred, n_config
  ):
      """data_gen_custom"""
      print("generate training data...")
      # data
      df = pd.read_csv(
          input_file,
          sep="\t",
          names=["date", "迁出省份", "迁出城市", "迁入省份", "迁入城市", "人数"],
      )
      # 只需要2020年的数据
      df["date"] = pd.to_datetime(df["date"], format="%Y%m%d")
      df = df.set_index("date")
      df = df["2020"]
      city_df = pd.read_csv(city_file)
      input_df = pd.DataFrame()
  
      out_df_wuhan = df[df["迁出城市"].str.contains("武汉")]
      for i in city_df["city"]:
          # 筛选迁入城市
          in_df_i = out_df_wuhan[out_df_wuhan["迁入城市"].str.contains(i)]
          # 确保按时间升序
          # in_df_i.sort_values("date",inplace=True)
          # 按时间插入
          in_df_i.reset_index(drop=True, inplace=True)
          input_df[i] = in_df_i["人数"]
  
      # 替换Nan值
      input_df = input_df.replace(np.nan, 0)
  
      x = input_df
      y = pd.read_csv(output_file)
      # 删除第1列
      x.drop(
          x.columns[x.columns.str.contains("unnamed", case=False)],
          axis=1,
          inplace=True,
      )
      y = y.drop(columns=["date"])
  
      # 剔除迁入武汉的数据
      x = x.drop(columns=["武汉"])
      y = y.drop(columns=["武汉"])
  
      # param
      n_val, n_test = n_config
      n_train = len(y) - n_val - n_test - 2
  
      # (?,26,74,1)
      df = pd.DataFrame(columns=x.columns)
      for i in range(len(y) - n_pred + 1):
          df = df.append(x[i : i + n_his])
          df = df.append(y[i : i + n_pred])
      data = df.values.reshape(
          -1, n_his + n_pred, n, 1
      )  # n == num_nodes == city num
  
      x_stats = {"mean": np.mean(data), "std": np.std(data)}
  
      x_train = data[:n_train]
      x_val = data[n_train : n_train + n_val]
      x_test = data[n_train + n_val :]
  
      x_data = {"train": x_train, "val": x_val, "test": x_test}
      dataset = Dataset(x_data, x_stats)
      print("generate successfully!")
  
      return dataset
  
file_path: PGL/legacy/examples/stgcn/data_loader/data_utils.py
imports: import numpy
  import pandas
  from utils.math_utils import z_score
label_desc: Use image node_id 3 for calling a global function with example usage: data_gen_custom(input_file, output_file, city_file, n, n_his, n_pred, n_config) and returns: dataset