title: Appending items to a DataFrame in a loop from a nested list
body: <p>I have 7 API responses which follow this structure:</p>
  <p>I named the response <code>a</code>.</p>
  <pre><code>a = {
      'kind': 'youtubeAnalytics#resultTable',
      'columnHeaders': [{
          'name': 'video',
          'columnType': 'DIMENSION',
          'dataType': 'STRING'
      }, {
          'name': 'views',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'likes',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'dislikes',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'shares',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'estimatedMinutesWatched',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'subscribersGained',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'averageViewDuration',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'comments',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'cardImpressions',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'cardClicks',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }, {
          'name': 'estimatedRevenue',
          'columnType': 'METRIC',
          'dataType': 'FLOAT'
      }, {
          'name': 'adImpressions',
          'columnType': 'METRIC',
          'dataType': 'INTEGER'
      }],
      'rows': [
          ['id_1', 6653, 95, 10, 12, 14913, 36, 134, 5, 42, 1, 0, 0],
          ['id_2', 1184, 18, 3, 2, 2397, 13, 121, 0, 15, 0, 0, 0],
          ['id_3', 1122, 29, 0, 10, 4464, 5, 238, 1, 8, 1, 0, 0],
          ['id_4', 1011, 5, 2, 1, 1361, 3, 80, 0, 4, 0, 0, 0],
          
       ]
  }
  </code></pre>
  <p>I am trying to get a simple structure where the columns are names from the <code>columnHeaders</code> key and values are items from the <code>rows</code> key.</p>
  <p>I tried:</p>
  <pre><code># produce an empty df with all of the required columns
  df2 = pd.DataFrame(columns=[x['name'] for x in a['columnHeaders']])
  
  # add the values in from the list
  df2.loc[len(df)] = [x for x in a['rows'] # here I get an error
  </code></pre>
  <blockquote>
  <p>ValueError: cannot set a row with mismatched columns</p>
  </blockquote>
  <p>Which makes sense because <code>len(a['rows'])</code> is <code>4</code>.</p>
  <pre><code># This way I successfully add the first list as values to my df2
  df2.loc[len(df)] = [x for x in a['rows'][0]]
  </code></pre>
  <p>Omitted some columns for visibility to show the desired structure:</p>
  <pre><code>    video   views   likes   dislikes    shares  estimatedMinutesWatched subscribersGained   averageViewDuration comments    cardImpressions cardClicks  
  0   id_1    6653    95      10          12      14913                   36                  134                 5           42              1   
  </code></pre>
  <p>My goal is to query the API 7 times and add each <code>list</code> produced in <code>rows</code> key as a values to my <code>df</code>.</p>
  <p>Below is the API request that returns the structure mentioned above and what I tried:</p>
  <pre><code># create an empty `df` with the desired columns
  
  df = execute_api_request(
      youtubeAnalytics.reports().query,
      ids='channel==MINE',
      startDate=datetime.today().strftime('%Y-%m-%d'),
      endDate=datetime.today().strftime('%Y-%m-%d'),
      dimensions='video',
   metrics='views,likes,dislikes,shares,estimatedMinutesWatched,subscribersGained,averageViewDuration,comments,cardImpressions,cardClicks,estimatedRevenue,adImpressions',
      maxResults=200,
      sort='-views'
  )
  
  df = pd.DataFrame(columns=[x['name'] for x in  res['columnHeaders']])
  </code></pre>
  <pre><code>print(df)
  
  Empty DataFrame
  Columns: [video, views, likes, dislikes, shares, estimatedMinutesWatched, subscribersGained, averageViewDuration, comments, cardImpressions, cardClicks, estimatedRevenue, adImpressions]
  Index: []
  </code></pre>
  <pre><code># then I try to iterate 7 times and using timedelta move backwards. Not sure how to append the data to the df
  for i in range(1,8):
      # add the reponse to df somehow
      execute_api_request(
      youtubeAnalytics.reports().query,
      ids='channel==MINE',
      startDate=(datetime.today()-timedelta(i+1)).strftime('%Y-%m-%d'),
      endDate=(datetime.today()-timedelta(i)).strftime('%Y-%m-%d'),
      dimensions='video',
      metrics='views,likes,dislikes,shares,estimatedMinutesWatched,subscribersGained,averageViewDuration,comments,cardImpressions,cardClicks,estimatedRevenue,adImpressions',
      maxResults=200,
      sort='-views'
  )
  </code></pre>
  <p>What would be the best way to achieve the desired result?</p>