Merge and update dataframes based on a subset of their columns

后端 未结 3 2040
梦谈多话
梦谈多话 2021-01-20 01:45

I wonder whether there is the fastest code to replace the two for loops, assuming the df size is very large. In my real case, each dataframe is 200 rows and 25 columns.

3条回答
  •  醉酒成梦
    2021-01-20 02:34

    I also figured out that below code does what I want and is much faster than two for loops.

    df1.loc[[1,2,5],[1,3]] = df2.loc[[1,2,3],[1,2]].values
    

提交回复
热议问题