How would I be able to convert table structured data to a dict/graph structure in python/pandas, to be used for force graphs in D3?
<p>I'm stuck in converting this csv:</p>

<pre><code>"","Destination","Source"
"1","New York","Chicago"
"2","Denver","Chicago"
"3","Los Angeles","Boston"
"4","Colorado","Indianapolis"
</code></pre>

<p>to a format like this:</p>

<pre><code>[
    {
        "name": "Chicago",
        "target": [
            1,
            2
        ]
    },
    {
        "name": "New York",
        "target": []
    },
    {
        "name": "Denver",
        "target": []
    },
    {
        "name": "Los Angeles",
        "target": []
    },
    {
        "name": "Boston",
        "target": [
            3
        ]
    },
    {
        "name": "Indianapolis",
        "target": [
            6
        ]
    },
    {
        "name": "Colorado",
        "target": []
    }
]
</code></pre>

<p>where target is the index number of the node its connected to.</p>

<p>I'm trying to do this in python because I want to post this data to a DB and pull from the front end to do D3 stuff.</p>

<p>I tried with pandas too, but couldn't it in this format. pretty frustrated now! Any help would be GREATLY appreciated!!</p>

<p>Thank you!</p>