Zip Pandas Dataframes Into A New Dataframe
I have 2 dataframes: df_A country_codes 0 4 1 8 2 12 3 16 4 24 and df_B continent_codes 0 4 1
Solution 1:
The following code will do as you want :
pd.concat([df1, df2], axis=1)
Output:
country_codes continent_codes
0 4 4
1 8 3
2 12 5
3 16 6
4 24 5
Solution 2:
From the comments:
I feel like this is too simple, but may I suggest:
df_A['continent_codes'] = df_B['continent_codes']
print(df_A)
Output:
country_codes continent_codes
0 4 4
1 8 3
2 12 5
3 16 6
4 24 5
Post a Comment for "Zip Pandas Dataframes Into A New Dataframe"