code: import argparse
  
  import pandas as pd
  
  if __name__ == '__main__':
      parser = argparse.ArgumentParser()
      # debug
      parser.add_argument('feature_csv', help='feature csv file')
      parser.add_argument('tags_csv', help='tags csv. extract dataset=1 samples')
      parser.add_argument('out_csv', help='feature csv file')
  
      args = parser.parse_args()
  
      feat_df = pd.read_csv(args.feature_csv)
      tags = pd.read_csv(args.tags_csv)
      feat_cols = list(feat_df.columns)
      merged = pd.merge(feat_df, tags, on=['mask'])
      merged = merged[merged['dataset'] == 1]
      merged.to_csv(args.out_csv, columns=feat_cols, index=None)
  
apis: pandas.read_csv pandas.merge