title: how to form correct JSON by reading csv data and use in API payload
body: <p>I am using the below code to form a JSON, by reading data from csv</p>
  <pre><code>df = pd.read_csv('/testdata.csv', dtype={
  
   &quot;debt_type&quot;: str,
   &quot;debt_amount&quot;: int,
   &quot;interest_rate&quot;: float,
   &quot;total_monthly_payment&quot;: int,
   &quot;remaining_term,interest_payable&quot;: int})
  
  finalList = []
  finalDict = {}
  grouped = df.groupby(['debt_type'])
  for key, value in grouped:
      dictionary = {}
  
      j = grouped.get_group(key).reset_index(drop=True)
      dictionary['debt_type'] = j.at[0, 'debt_type']
  
      dictList = []
      anotherDict = {}
      for i in j.index:
          anotherDict['debt_amount'] = j.at[i, 'debt_amount']
          anotherDict['interest_rate'] = j.at[i, 'interest_rate']
          anotherDict['total_monthly_payment'] = j.at[i, 'total_monthly_payment']
          anotherDict['remaining_term'] = j.at[i, 'remaining_term']
          anotherDict['interest_payable'] = j.at[i, 'interest_payable']
  
          dictList.append(anotherDict)
          dictionary['loan_info'] = dictList
          finalList.append(dictionary)
          finalDict = finalList
  </code></pre>
  <p>and want to achieve below</p>
  <pre><code>{&quot;loan_info&quot;:{&quot;debt_amount&quot;:9000,&quot;interest_rate&quot;:23,&quot;total_monthly_payment&quot;:189,&quot;remaining_term&quot;:129,&quot;interest_payable&quot;:15356},&quot;debt_type&quot;:&quot;credit_card&quot;}
  </code></pre>
  <p>however, what I am getting is below</p>
  <pre><code>[{'debt_type': 'credit_card', 'loan_info': [{'debt_amount': 9000, 'interest_rate': 12.2, 'total_monthly_payment': 189, 'remaining_term': 129, 'interest_payable': 15256}]}]
  </code></pre>
  <p>can anyone help here. thanks in advance.</p>