def _collapse_metadata(mapping_f, collapse_fields):
 (mapping_data, header, _) = parse_mapping_file(mapping_f)
 sample_md = pd.DataFrame(mapping_data, columns=header)
 grouped = sample_md.groupby(collapse_fields)
 collapsed_md = grouped.agg((lambda x: tuple(x)))
 return collapsed_md

def _collapse_metadata ( mapping_f , collapse_fields ) : ( mapping_data , header , _ ) = parse_mapping_file ( mapping_f ) sample_md = pd . DataFrame ( mapping_data , columns = header ) grouped = sample_md . groupby ( collapse_fields ) collapsed_md = grouped . agg ( ( lambda x : tuple ( x ) ) ) return collapsed_md
load a mapping file into a dataframe and then collapse rows parameters mapping_f : file handle or filepath the sample metadata mapping file .