I'd like to add data from a dataframe to a another dataframe.
Here my first data frame: df
Here my second dataframe: dff
df.append(dff, ignore_index=True, sort=False)
And it results me that:
Appending is adding two dataframe 'on top of each other' so you add rows. If you want to add new columns to your dataframe from another dataframe, you use join or merge especially if you have a key column where you can merge, which is in your case Postal Code
In pandas we use pd.merge for merging two dataframes with each other like the followng:
df_final = pd.merge(df, dff, on='Postal Code')
Postal Code Borough Neighbourhood Lattitude Longitude
0 M1B Scarborough Rouge 43.806686 -79.194353
1 M1B Scarborough Malvern 43.806686 -79.194353
2 M1C Scarborough Port Union 43.784535 -79.160497
3 M1C Scarborough Rouge Hill 43.784535 -79.160497
4 M1C Scarborough Highland Creek 43.784535 -79.160497
df.combine_first(dff)??df.merge(dff, on='Postal Code'), or it has to be added based on other logic?df.merge(dff)should be sufficient, sincePostal Codeis the only common column