Off topic:How to create multidimensional dictionary in python?
0
0
Entering edit mode
5.8 years ago

Hi All,

The input data is as below:

chr1    a   3   6
chr1    b   4   5
chr1    a   2   5
chr1    c   4   5
chr2    d   5   6
chr2    d   2   3
chr2    c   4   7
chr3    e   6   7

How can I get dicts like the following?

dict1:

 {'chr1': {'a': '3-6,2-5', 'b': '4-5', 'c': '4-5'}, 'chr2': {'d': '5-6,2-3', 'c': '4-7'}, 'chr3': {'e': '6-7'}}

dict2:

{'chr1': {'a': ['3-6','2-5'], 'b': ['4-5'], 'c': ['4-5']}, 'chr2': {'d': ['5-6','2-3'], 'c': ['4-7']}, 'chr3': {'e': ['6-7']}}

Thanks

python dataframe gtf • 2.5k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3180 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6