title: Inserting Pandas Dataframe row to list, with headers for each value
body: <p>I have a Dataframe being returned from a google trends API and contains values for date, keyword and search volume. I need to return a list of lists that will contain the following <code>keyword, date 1, value 1, date 2, value 2, date 3, value 3, date n, value n...]</code> </p>
  
  <p>I have the following function that will take a set of keywords and send them to the API, then converts the returned dataframe to a list</p>
  
  <pre><code>def list_to_api(keyword_list):
  
      (pytrends.build_payload(keyword_list, cat=0, timeframe='today 12-m', geo='', gprop=''))
      df = (pytrends.interest_over_time())
      google_data_list = df.values.tolist()
      print(type(google_data_list))
      print("Resting 5 seconds for next API Call")
      print("Converted to  list ")
      insert_list.append(google_data_list)
  </code></pre>
  
  <p>The following screenshot1 shows what the output looks like as a dataframe</p>
  
  <p><a href="https://i.stack.imgur.com/v1QGY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v1QGY.png" alt="dataframe"></a></p>
  
  <p>That gives the list output <code>[[[1, 93, 29, 7, 0, False], [1, 95, 31, 8, 0, False], [1, 91, 31, 8, 0, False], [1, 93, 34, 7, 0, False], [1, 96, 32, 8, 0, False]</code></p>
  
  <p>I have transposed the dataframe by updating these two lines </p>
  
  <pre><code>df = (pytrends.interest_over_time())
  google_data_list = df_.values.tolist()
  </code></pre>
  
  <p>to  </p>
  
  <pre><code>df_new = df.transpose()
  google_data_list = df_new.values.tolist()
  </code></pre>
  
  <p>Screenshot2 shows what this table looks like</p>
  
  <p><a href="https://i.stack.imgur.com/hGVPV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hGVPV.png" alt="df transposed"></a>
   and it
  which creates the list output for the first two values:</p>
  
  <pre><code>[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 
  [92, 94, 92, 94, 98, 100, 85, 87, 88, 87, 95, 89, 89, 93, 94, 88, 86, 87, 84,
   87, 82, 80, 81, 81, 76, 78, 78, 77, 73, 77, 76, 76, 79, 73, 87, 88, 91, 92, 88, 90, 
  85, 88, 95, 94, 89, 91, 91, 91, 89, 85, 86]
  </code></pre>
  
  <p>So for the first example my desired output would be </p>
  
  <pre><code>[0 balance transfer, date1, 1, date2, 1, date3, 1, dateN, 1...]
  </code></pre>
  
  <p>But I am struggling to take the date from the header and adding it alongside the corresponding value for the list. Any help much appreciated.</p>