Created
July 23, 2016 01:59
-
-
Save radusuciu/4bd636991702984bb7eb76dba6a7c916 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sorted_data = sorted(data, key=lambda x: x['Sample name']) | |
by_sample_name = itertools.groupby(sorted_data, key=lambda x: x.get('Sample name')) | |
grouped = [] | |
for name, g in by_sample_name: | |
d = list(g) | |
grouped.append( | |
'\t'.join([ | |
name, | |
str(len(d)), | |
','.join(set([x['Primary site'] for x in d])), | |
','.join(set([y['Histology subtype 1'] for y in d])) | |
]) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment