title: Using python in postgres and this error pops up
body: <p>Getting this error:</p>
  
  <pre><code>Connection successful
  Database Created Successfully
  Connected to babynames database.
  Traceback (most recent call last):
    File "C:/Users/Joseph/Desktop/INFO153 Final/Info153PartII.py", line 44, in &lt;module&gt;
      cur.execute('insert into boys values ({},{},{},{});'.format(row.tolist()[0],"'"+row.tolist()[1]+"'",row.tolist()[2],row.tolist()[3]))
  TypeError: can only concatenate str (not "float") to str
  </code></pre>
  
  <pre><code>import pandas as pd
  
  df_boys = pd.read_csv('babynames.txt', delimiter=' ',header=None, usecols=(0,1,2,3) )
  
  df_boys.columns = ["Rank", "Name", "Total Babies", "Total Percentage"]
  
  df_girls = pd.read_csv('babynames.txt', delimiter=' ',header=None, usecols=(0,4,5,6) )
  df_girls.columns = ["Rank", "Name", "Total Babies", "Total Percentage"]
  
  #check the imported data
  df_boys.head()
  df_girls.head()
  
  #psycopg2 library for connecting to PostgreSQL database
  
  import psycopg2
  
  conn = psycopg2.connect(database="postgres", user="postgres", password="postgres", host="127.0.0.1", port="5432")
  conn.autocommit = True
  print ("Connection successful")
  
  #Create babynames database
  
  cur = conn.cursor()
  cur.execute('CREATE DATABASE babynames;')
  print ("Database Created Successfully")
  
  #connect to babynames database
  
  conn_babynames = psycopg2.connect(database="babynames", user="postgres", password="postgres", host="127.0.0.1", port="5432")
  conn_babynames.autocommit = True
  print ("Connected to babynames database.")
  cur = conn_babynames.cursor()
  
  #create tables for boys and girls
  
  cur.execute('CREATE TABLE Boys (Rank integer, Name varchar(25), Total_Babies float, Total_Percentage float);')
  cur.execute('CREATE TABLE Girls (Rank integer, Name varchar(25), Total_Babies float, Total_Percentage float);')
  
  #import data from dataframe to table using insert into statement
  
  for i, row in df_boys.iterrows():
      cur.execute('insert into boys values ({},{},{},{});'.format(row.tolist()[0],"'"+row.tolist()[1]+"'",row.tolist()[2],row.tolist()[3]))
  
  for i, row in df_girls.iterrows():
      cur.execute('insert into girls values ({},{},{},{});'.format(row.tolist()[0],"'"+row.tolist()[1]+"'",row.tolist()[2],row.tolist()[3]))
  
  #execute sql queries and display result of analysis
  
  cur.execute("select sum(total) as t_children from ( select sum(Total_Babies) as total from boys union select sum(Total_Babies) as total from girls) as t")
  total_babies=cur.fetchone()
  print("Total babies born that year = ",total_babies[0])
  
  cur.execute("select total from ( select sum(Total_Babies) as total from boys union select sum(Total_Babies) as total from girls) as t")
  babies=cur.fetchall()
  if (babies[0]&gt;babies[1]):
      print("More boys were born in that year")
  else:
      print("More girls were born in that year")
  
  cur.execute("select name from boys where Total_Babies&gt; {}".format(total_babies[0]/2))
  babies=cur.fetchall()
  print(babies)
  
  cur.execute("select name from girls where Total_Babies&gt; {}".format(total_babies[0]/2))
  babies=cur.fetchall()
  print(babies)```
  
  </code></pre>