-1

My first dataframe is something like this:

df1=pd.DataFrame({'ID':['514401202200037121','514401202200037334','514401202200037010','514401202200037210','514401202200036890'], 'ModEff':['0.207','0.205','0.211','0.204','0.206'], 'Rs':['0.297020','0.297250','0.296899','0.297111','0.297035'], 'Isc':['11.296','11.248','11.287','11.198','11.301']})

Second dataframe contains same ID numbers but they are random and not on same index.

df2=pd.DataFrame({'ID':['514401202200037334','514401202200037010', '514401202200037210','514401202200036890','514401202200037121'],'No':['50653','50653','50653','50653','50653']})

My goal is to get raw data (all columns) from first df to second one for matching ID numbers. However, I am not able to align them by ID.

Since I'm new to code, and none of the codes I've tried works, I'm posting without code sample.

*

2 Answers2

0

Please let me know if this works:

pd.merge(df1, df2, on='ID')
Nuri Taş
  • 3,828
  • 2
  • 4
  • 22
0

df2.merge(df1)

This works as both dataframes have the same "key".