Reputation: 2134
I want to bring three data frames into a single one .All data frames have a single column .
org_city_id=p.DataFrame(training_data['origcity_id'])
pol_city_id=p.DataFrame(training_data['pol_city_id'])
pod_city_id=p.DataFrame(training_data['pod_city_id'])
All have 100 records in it so my goal is to bring them into a single data frame which will then contain 300 records .My below code is not working
org_city_id.append([pol_city_id,pod_city_id])
the total number of records in org_city_id is still 100 .
Can someone please suggest .
Upvotes: 6
Views: 12099
Reputation: 294258
dfs = [org_city_id, pol_city_id, pod_city_id]
pd.concat([df.squeeze() for df in dfs], ignore_index=True)
Upvotes: 2
Reputation: 32095
Get a single column name for all your dataframes:
org_city_id.columns = pol_city_id.columns = pod_city_id.columns = 'Final Name'
Then concat them:
pd.concat([org_city_id,pol_city_id,pod_city_id])
Upvotes: 3