Hi I am trying to make a new column based on combination of values in two columns
the original df I have is below
| id | code_1 | code_2 |
| --- | -------- | ----- |
| A0 | 001 | X1 |
| A1 | 001 | X2 |
| A2 | 001 | x3 |
| A3 | 001 | x4 |
| A4 | 002 | X1 |
| A5 | 002 | X2 |
regardless of the id in first column, I am only considering the combination of second and third column which are 'code_1' and 'code_2'
If the 'code_1' is 001 and 'code_2' is x1, x2 and x3, I want to create new column and give Y1
If the 'code_1' is 001 and 'code_2' is x4, then I want to give Y2
If the 'code_2' is 002 and 'code_2' is x1 and x2, then I want to give Z1
So, the final output for this table would look like below:
| id | code_1 | code_2 | new_code |
| --- | -------- | ----- | -------- |
| A0 | 001 | X1 | Y1 |
| A1 | 001 | X2 | Y1 |
| A2 | 001 | x3 | Y1 |
| A3 | 001 | x4 | Y2 |
| A4 | 002 | X1 | Z1 |
| A5 | 002 | X2 | Z1 |
Thank you