Simple Join Of Two Data Frames In Pandas
I have two data frames in a Python program using Pandas. I am new to Pandas. Each one has a number of columns and rows - the first is similar to: calc_1 calc_2 calc_3 0 34.3
Solution 1:
Use pd.concat
and pass axis=1
to concatenate column-wise:
In [37]:
pd.concat([df,df1], axis=1)
Out[37]:
calc_1 calc_2 calc_3 gender age
034.343.142.0 M 2523.04.05.0 M 2736.16.16.2 M 2744.24.34.5 F 36
or join
:
In [38]:
df.join(df1)
Out[38]:
calc_1 calc_2 calc_3 gender age
034.343.142.0 M 2523.04.05.0 M 2736.16.16.2 M 2744.24.34.5 F 36
Or merge
and set left_index=True
and right_index=True
:
In [41]:
df.merge(df1, left_index=True, right_index=True)
Out[41]:
calc_1 calc_2 calc_3 gender age
034.343.142.0 M 2523.04.05.0 M 2736.16.16.2 M 2744.24.34.5 F 36
Post a Comment for "Simple Join Of Two Data Frames In Pandas"