Pandas fill missing values in dataframe from another dataframe

前端 未结 5 876
遥遥无期
遥遥无期 2020-11-28 12:10

I cannot find a pandas function (which I had seen before) to substitute the NaN\'s in a dataframe with values from another dataframe (assuming a common index which can be sp

5条回答
  •  一生所求
    2020-11-28 12:40

    As I just learned, there is a DataFrame.combine_first() method, which does precisely this, with the additional property that if your updating data frame d2 is bigger than your original df, the additional rows and columns are added, as well.

    df = df.combine_first(d2)
    

提交回复
热议问题