title: How to properly format a CSV using pandas
body: <p>I have a JSON with multiple objects and dictionaries, my JSON is below:</p>
  
  <pre><code>{
     "lastMonth":{
      "totalCost":4120.6241,
     "cpu_avg_partition":{
       "10":{
          "count":1,
          "cost":0.0,
          "value":10
          "period":"lastMonth",
          "resourceTypes":{
              "db":{
                  "cost":842.8003
  </code></pre>
  
  <p>and etc...... etc.</p>
  
  <p>And I have Python pandas code as below where I converted to CSV file but not in expected format</p>
  
  <p>Python code:</p>
  
  <pre><code>import json,ast
  import csv
  import pandas as pd
  from pandas import compat
  
  compat.PY3 = True
  
  df=pd.read_json("monthly_costformatter_data.json")
  new_df = df.transpose() 
  column_name = new_df.columns.values
  new_df[['totalCost','cpu_avg_partition','providers','period',
          'resourceTypes','accounts','running_hours_partition',
          'projects']].to_csv('test10pands.csv',index=True,encoding='utf-8')
  </code></pre>
  
  <p>And the output is as below in CSV file</p>
  
  <pre><code>                totalCost   cpu_avg_partition   providers   period  
    resourceTypes accounts    running_hours_partition projects
    currency_code GBP GBP GBP GBP GBP GBP GBP GBP
    currentMonth  1769.9801   {u'10': {u'count': 0, u'cost': 0.0, u'value': 
   10}, u'100': {u'count': 0, u'cost': 0.0, u'value': 100}, u'5': {u'count': 
   10, 
    idmap                     {u'188f6226-59d8-4a7c-9fdb-f32f4f0885ff':  
   u'628455167342'}       {u'813': u'ACP PM Work'}
   lastMonth  4120.6241   {u'10': {u'count': 1, u'cost': 0.0, u'value': 10}, 
   u'100': {u'count': 0, u'cost': 0.0, u'value': 100}, u'5': {u'count': 16, 
  u'cost': 0.0, u'value': 5}, u'50': {u'count': 0, u'cost': 0.0, u'value': 50},
  </code></pre>
  
  <p>BUT I also removed the you unicode character using</p>