Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appending one data frame into another

Tags:

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 .

like image 342
arpit joshi Avatar asked Sep 02 '16 22:09

arpit joshi


1 Answers

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])
like image 147
Zeugma Avatar answered Sep 24 '22 16:09

Zeugma