Question: (Closed) How to create multidimensional dictionary in python?
0
gravatar for Santiansiye
16 months ago by
Santiansiye0 wrote:

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

dataframe python gtf • 949 views
ADD COMMENTlink modified 16 months ago • written 16 months ago by Santiansiye0
1

Not a bioinformatics question. This is about python programming, have you looked on StackOverflow, like for example this post ?

ADD REPLYlink written 16 months ago by Jean-Karim Heriche21k

Can you explain the rationale of your data structure and how such can help your downstream analyses? Else, I'm interpreting this as a homework question.

ADD REPLYlink written 16 months ago by Eric Lim1.4k

Hello Santiansiye!

We believe that this post does not fit the main topic of this site.

Not a bioinformatics question!

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 16 months ago by lakhujanivijay4.5k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1878 users visited in the last hour