title: Using pandas to convert csv into nested json with dynamic strucutre
body: <p>I am new to python and now want to convert a csv file into json file. Basically the json file is nested with dynamic structure, the structure will be defined using the csv header.</p>
  <p>From csv input:</p>
  <pre><code>ID, Name, person_id/id_type, person_id/id_value,person_id_expiry_date,additional_info/0/name,additional_info/0/value,additional_info/1/name,additional_info/1/value,salary_info/details/0/grade,salary_info/details/0/payment,salary_info/details/0/amount,salary_info/details/1/next_promotion
  1,Peter,PASSPORT,A452817,1-01-2055,Age,19,Gender,M,Manager,Monthly,8956.23,unknown
  2,Jane,PASSPORT,B859804,2-01-2035,Age,38,Gender,F,Worker, Monthly,125980.1,unknown
  </code></pre>
  <p>To json output:</p>
  <pre><code>[
   {
     &quot;ID&quot;: 1,
     &quot;Name&quot;: &quot;Peter&quot;,
     &quot;person_id&quot;: {
        &quot;id_type&quot;: &quot;PASSPORT&quot;,
        &quot;id_value&quot;: &quot;A452817&quot;
     },
     &quot;person_id_expiry_date&quot;: &quot;1-01-2055&quot;,
     &quot;additional_info&quot;: [
        {
           &quot;name&quot;: &quot;Age&quot;,
           &quot;value&quot;: 19
        },
        {
           &quot;name&quot;: &quot;Gender&quot;,
           &quot;value&quot;: &quot;M&quot;
        }
     ],
     &quot;salary_info&quot;: {
        &quot;details&quot;: [
           {
              &quot;grade&quot;: &quot;Manager&quot;,
              &quot;payment&quot;: &quot;Monthly&quot;,
              &quot;amount&quot;: 8956.23
           },
           {
              &quot;next_promotion&quot;: &quot;unknown&quot;
           }
        ]
     }
  },
   {
     &quot;ID&quot;: 2,
     &quot;Name&quot;: &quot;Jane&quot;,
     &quot;person_id&quot;: {
        &quot;id_type&quot;: &quot;PASSPORT&quot;,
        &quot;id_value&quot;: &quot;B859804&quot;
     },
     &quot;person_id_expiry_date&quot;: &quot;2-01-2035&quot;,
     &quot;additional_info&quot;: [
        {
           &quot;name&quot;: &quot;Age&quot;,
           &quot;value&quot;: 38
        },
        {
           &quot;name&quot;: &quot;Gender&quot;,
           &quot;value&quot;: &quot;F&quot;
        }
     ],
     &quot;salary_info&quot;: {
        &quot;details&quot;: [
           {
              &quot;grade&quot;: &quot;Worker&quot;,
              &quot;payment&quot;: &quot; Monthly&quot;,
              &quot;amount&quot;: 125980.1
           },
           {
              &quot;next_promotion&quot;: &quot;unknown&quot;
           }
        ]
     }
  }
  ]
  </code></pre>
  <p>Is this something can be done by the existing pandas API or I have to write lots of complex codes to dynamically construct the json object? Thanks.</p>