I have a dataFrame like this:
id asn orgs
0 3320 {'Deutsche Telekom AG': 2288}
1 47886 {'Joyent': 16, 'Equinix (Netherlands) B.V.': 7}
2 47601 {'fusion services': 1024, 'GCE Global Maritime':16859}
3 33438 {'Highwinds Network Group': 893}
I would like to sort the 'orgs' column which is actually a dictionary and then extract get the pair(k,v) with the highest values in two different columns. Like this:
id asn org value
0 3320 'Deutsche Telekom AG' 2288
1 47886 'Joyent' 16
2 47601 'GCE Global Maritime' 16859
3 33438 'Highwinds Network Group' 893
Currently I am running this code but it does not properly sort, and then I am not sure how to extract the pair with highest value.
df.orgs.apply(lambda x : sorted(x.items(),key=operator.itemgetter(1),reverse=True))
which gave me a list like this:
id asn orgs
0 3320 [('Deutsche Telekom AG', 2288)]
1 47886 [('Joyent', 16),( 'Equinix (Netherlands) B.V.', 7)]
2 47601 [('GCE Global Maritime',16859),('fusion services', 1024)]
3 33438 [('Highwinds Network Group', 893)]
Now how can I put the key and the value of the highest into two seperate columns? Can anybody help?