I have a data frame with columns "A", "B", and "Dict"
- "Dict" has values of either "A" or "B" , which indicates the correct columns that values should be in for each row
- columns "A" or "B" have numeric values
For example:
A B Dict
0 123 B
0 123 A
123 0 A
I want to move the value in "B" to "A" if "Dict" has A in the same row, but keep other rows the same if the "Dict" has correct matchings (the value should be in the column that "Dict" indicates, otherwise it will be 0):
A B Dict
0 123 B
123 0 A
123 0 A
Does anyone know how I should proceed?
Edit: There are negative values in the columns too. Sorry I should've clarified.