-1

I have one dataframe

Name    Value1
IJK     127
LMN     987
PQR     678

And other as

Name    Value2
IJK     45
LMN     7
PQR     67
KPI     988

How can I create new dataframe

Name    Value2    Value1
IJK     45        127
LMN     7         987
PQR     67        678
KPI     988
spd
  • 334
  • 1
  • 12

2 Answers2

0

Use pd.merge.

If both have Name as column:

df.merge(df2, on="Name", how="outer")

If both have Name as index:

df.merge(df2, left_index=True, right_index=True, how="outer")
Rawson
  • 2,637
  • 1
  • 5
  • 14
0

This is a merge:

df = df1.merge(df2, on='Name', how='outer')

Documentation can be found here.

gaucho
  • 141
  • 4