0

I have two df's:

df1:

       date                         point_id  
0      2010-10-11               121    
1      2010-10-11               433         
2      2010-10-11               6618   

df2:

          id       point_id
0         11       433
1         22       121
2         97       6618

Now I want the df to be like:

       date                     point_id     cal_id 
0      2010-10-11               121          22
1      2010-10-11               433          11
2      2010-10-11               6618         97

What i try:

df1['cal_id'] = df1.where(df1['point_id']==df2['point_id']).notna()

with error:

ValueError: Can only compare identically-labeled Series objects
GTr Tin
  • 3
  • 1

1 Answers1

0

Use merge

df_merged = df1.merge(df2, how="inner", on="point_id")

See here for more.

Philipp
  • 652
  • 2
  • 10
  • 28