0

df1

col1 col2
 1    A
 1    A
 2
 3
 4    D
 4    D

df2

coln1   coln2
  1      A
  2      B
  3      c
  4      D


 df1(col2) = df1(col2).map(df2.set_index(coln1)[coln2])

Trying to fill col2 value in df1 from df2 where df1.col1 = df2.coln1

here both datasets are large, imported from csv files, Please help me to correct above code.

If below error comes, how to handle this also

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

ashish
  • 239
  • 2
  • 6
  • 13

0 Answers0