title: How to convert GA API JSON to Pandas DataFrame
body: <p>I'm developing a connector Google Analytics to MS SQL Server and in order to load the GA info to a DB Table the API response should be normalized. I thought pd.Dataframe is not a bad idea. </p>
  
  <p>API Responce v3</p>
  
  <pre><code>{'columnHeaders': [{'columnType': 'DIMENSION',
                      'dataType': 'STRING',
                      'name': 'ga:yearMonth'},
                     {'columnType': 'DIMENSION',
                      'dataType': 'STRING',
                      'name': 'ga:year'},
                     {'columnType': 'METRIC',
                      'dataType': 'INTEGER',
                      'name': 'ga:users'},
                     {'columnType': 'METRIC',
                      'dataType': 'INTEGER',
                      'name': 'ga:sessions'}],
   'containsSampledData': False,
   'id': 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:*****&amp;dimensions=ga:yearMonth,ga:year&amp;metrics=ga:users,ga:sessions&amp;start-date=2019-01-01&amp;end-date=2019-01-31&amp;start-index=1',
   'itemsPerPage': 1000,
   'kind': 'analytics#gaData',
   'profileInfo': {'accountId': '****',
                   'internalWebPropertyId': '***',
                   'profileId': '***',
                   'profileName': 'All Web Site Data',
                   'tableId': 'ga:178030957',
                   'webPropertyId': 'UA-****-1'},
   'query': {'dimensions': 'ga:yearMonth,ga:year',
             'end-date': '2019-01-31',
             'ids': 'ga:****',
             'max-results': 1000,
             'metrics': ['ga:users', 'ga:sessions'],
             'start-date': '2019-01-01',
             'start-index': 1},
   'rows': [['201901', '2019', '3677', '4501']],
   'selfLink': 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:****&amp;dimensions=ga:yearMonth,ga:year&amp;metrics=ga:users,ga:sessions&amp;start-date=2019-01-01&amp;end-date=2019-01-31&amp;start-index=1',
   'totalResults': 1,
   'totalsForAllResults': {'ga:sessions': '4501', 'ga:users': '3677'}}
  </code></pre>
  
  <p>I want to include in df the following params: query info, profileInfo and rows.</p>
  
  <p>So far I've tried accessing json through json_normalize function, but it doesn't convert the response properly :( </p>
  
  <pre class="lang-py prettyprint-override"><code> df_test=json_normalize(traffic_results)
  </code></pre>
  
  <p>It produces df with nested dicts</p>
  
  <p>Then I've tried to pass record_path and meta info:</p>
  
  <pre class="lang-py prettyprint-override"><code>df_example=json_normalize(traffic_results, record_path=['rows'], meta=[['query', 'dimensions'], ['query', 'metrics']])
  </code></pre>
  
  <p>Get rows and then dimensions and metrics, but it produces an error: </p>
  
  <p>ValueError: Length of values does not match length of index.</p>
  
  <p>But when I pass these args: </p>
  
  <pre class="lang-py prettyprint-override"><code>response_ga_report=json_normalize(traffic_results, record_path=['rows'], meta=[['query' , 'ids'], ['query' , 'dimensions']])
  </code></pre>
  
  <p>It works ok:</p>
  
  <pre class="lang-py prettyprint-override"><code>     0       1       2       3       query.ids      query.dimensions
  0   201901  2019    3677    4501    ga:178030957    ga:yearMonth,ga:year
  </code></pre>
  
  <p>I'm deeply stuck, have no idea how it can be converted. It's not mandatory to convert the response in DF.</p>