Below is my sample Dataframes and my expected result. How can I get the expected result. I tried using loop for i in range(len(df2)): for x in range(len(df1)):
and using if condition to compare column values and assign with .at method but getting KeyError: 0 error
Df1
| Index | acn | name | dob | Insert | Update | New |
|---|---|---|---|---|---|---|
| 0 | 6946 | THAPA | 25-04-1982 | NaN | NaN | NaN |
| 1 | 7012 | SEKE | 14-07-1966 | NaN | NaN | NaN |
| 2 | 5824 | SEKE | 14-07-1966 | NaN | NaN | NaN |
| 3 | 6946 | JOHN | 25-04-1982 | NaN | NaN | NaN |
Df2
| Index | acn | name | dob | id |
|---|---|---|---|---|
| 0 | 6946 | JOHN | 25-04-1982 | IKO7 |
| 1 | 5824 | SEKE | 14-07-1966 | GGF1 |
Expected Result
| Index | acn | name | dob | Insert | Update | New |
|---|---|---|---|---|---|---|
| 0 | 6946 | THAPA | 25-04-1982 | NaN | NaN | Create |
| 1 | 7012 | SEKE | 14-07-1966 | NaN | GGF1 | NaN |
| 2 | 5824 | SEKE | 14-07-1966 | GGF1 | NaN | NaN |
| 3 | 6946 | JOHN | 25-04-1982 | IKO7 | NaN | NaN |
How do I achieve this. Appreciate your help