I am new to pandas module. I have a small question regarding pandas merge method. Suppose I have two separate tables, as follows:
Original_DataFrame
machine weekNum Percent
M1 2 75
M1 5 80
M1 8 95
M1 10 90
New_DataFrame
machine weekNum Percent
M1 1 100
M1 2 100
M1 3 100
M1 4 100
M1 5 100
M1 6 100
M1 7 100
M1 8 100
M1 9 100
M1 10 100
I used merge method of pandas module, as follows:
pd.merge(orig_df, new_df, on='weekNum', how='left')
I get as follows:
machine weekNum Percent_x Percent_y
0 M1 2 75 100
1 M1 5 80 100
2 M1 8 95 100
3 M1 10 90 100
However, I am looking to fill up the skipped weekNums and put 100 for those rows to get the desired output as follows.
machine weekNum Percent
M1 1 100
M1 2 75
M1 3 100
M1 4 100
M1 5 80
M1 6 100
M1 7 100
M1 8 95
M1 9 100
M1 10 90
Can anyone please direct me how to proceed?