Replacing values of a column from another dataframe

前端 未结 2 1934
天命终不由人
天命终不由人 2021-01-25 08:12

Hi have a dataframe with 10000+ rows which looks like this -

df = pd.DataFrame([[\'110\', \'Demand\', 2344, 30953], 
                   [\'111\', \'Supply\', 353         


        
2条回答
  •  广开言路
    2021-01-25 08:52

    You can try this:

    extra.set_index(['Material','Title']).combine_first(df.set_index(['Material','Title'])).dropna().reset_index().astype(object) 
    

    output:

      Material   Title 201950  201951
    0      110  Demand   2344   30953
    1      111  Supply     10  321312
    2      112  Supply     20    2324
    3      113  Demand  24345    4542
    4      114  Supply     30  435623
    

提交回复
热议问题