Reputation: 75
I am trying to either merge or concatenate tables that I am generating through a loop in python. Here's what I have:
for i in [some_list]:
# replacing with the ith term to request that particular value
url = "https://some_url/%s" % str(i)
# accessing a table correspounding to my request
request = pd.read_html(url)[0]
#request1 is a table with the same columns as request
request1 = request1.merge(request,how = 'outer')
request1
Essentially I want to add on to my original request1 table which has the same columns as request table, However, I am getting an error: " You are trying to merge on object and float64 columns. If you wish to proceed you should use pd.concat"
Upvotes: 0
Views: 99
Reputation: 323276
You may want to use concat
dflist=[]
for i in some_list:
# replacing with the ith term to request that particular value
url = "https://some_url/%s" % str(i)
# accessing a table correspounding to my request
request = pd.read_html(url)[0]
dflist.append(pd.DataFrame(request))#Adding dataframe constructor here
request1=pd.concat(dflist)
Upvotes: 2