There are good_df and bad_df:
article=['A9911652','A9911653','A9911654','A9911659','A9911661']
price1 = [0.01,7041.33,0.01,0.01,6067.27]
price2 = [0.01,0.01,9324.63,0.01,6673.99]
price3 = [2980.31,2869.4,0.01,1622.78,0.01]
bad_df = pd.DataFrame(list(zip(article, price1, price2, price3)),columns =['article', 'price1', 'price2', 'price3'])
article=[ 'A9911652','A9911653','A9911654','A9911659','A9911661']
price1 = [ 5,7041.33,9846,4785.74,6067.27]
price2 = [np.NaN,562,9324.63,9841,6673.99]
price3 = [5,2869.4,6812,1622.78,3516]
good_df = pd.DataFrame(list(zip(article, price1, price2, price3)),columns =['article', 'price1', 'price2', 'price3'])
'bad_df:
article price1 price2 price3
0 A9911652 0.01 0.01 2980.31
1 A9911653 7041.33 0.01 2869.40
2 A9911654 0.01 9324.63 0.01
3 A9911659 0.01 0.01 1622.78
4 A9911661 6067.27 6673.99 0.01
'good_df:
article price1 price2 price3
0 A9911652 5.00 NaN 5.00
1 A9911653 7041.33 562.00 2869.40
2 A9911654 9846.00 9324.63 6812.00
3 A9911659 4785.74 9841.00 1622.78
4 A9911661 6067.27 6673.99 3516.00
I'd like to replace the 0.01s of the bad_df (columns 'price1', 'price2', 'price3') with values of good_df, if they are non NaN.
I thought of something like this:
s=good_df.set_index('article')['price1','price2', 'price3']
bad_df[s]=good_df['article'].map(s).good_df.s
Please help me with that.