title: pandas query with list variables
body: <p>I made a list of id's each value is is an type int </p>
  
  <pre><code>temp_id = [7922, 7018, 5650, 209, 21928, 2294, 10507, 3623]
  
  type(tempasn) 
  list
  </code></pre>
  
  <hr>
  
  <p>This works:</p>
  
  <pre><code>Temp = pd.read_sql("select count(*) as count\
                      from "+db+"\
                      where ids in (7922, 7018, 5650, 209, 21928, 2294, 10507, 3623)\
                      order by count desc limit 10", conn)
  </code></pre>
  
  <p>I want to take the variable of the list add it to my query</p>
  
  <p>This causes errors</p>
  
  <pre><code>Temp = pd.read_sql("select count(*) as count\
                      from "+db+"\
                      where ids in "+temp_id+"\
                      order by count desc limit 10", conn)
  
  
  TypeError: Can't convert 'list' object to str implicitly
  </code></pre>
  
  <p>I don't understand what I need to change here</p>
  
  <hr>
  
  <p><strong>Answer</strong></p>
  
  <p>Ended up taking the advise of the comments below and modified my loop which generates the temp_ids:</p>
  
  <pre><code>temp_id = []
  for id in df['ID']:
      if id and id not in temp_id:
          temp_id.append(str(ID))        
  
          #Convert to list format
  temp_id = ", ".join(temp_id)
  </code></pre>
  
  <p>2 things made this work :</p>
  
  <pre><code>str(ID) &amp; temp_id = ", ".join(temp_id)
  </code></pre>