'Conditionally replacing the value of one column with another in python
This is more or less how one dataframe is:
ID,WinnerID
5863, 13463
4506, 20345
4514, 21012
4543, 20476
I have another file that has some ID's from the ID column that I would like replace with WinnerID
Grade ID, etc.
6, 4543, bla bla bla
6, 44519, bla bla bla
6, 44483, bla bla bla
6, 5863, bla bla bla
6, 44532, bla bla bla
6, 5863, bla bla bla
6, 44496, bla bla bla
6, 4543, bla bla bla
I thought of some sort of merge? In sas I would do some logic like
if in1 and not in2 then ID = WinnerID
during a merge but I'm not as familiar with python
I want the resulting data to be:
Grade ID, etc.
6, 20476, bla bla bla
6, 44519, bla bla bla
6, 44483, bla bla bla
6, 13463, bla bla bla
6, 44532, bla bla bla
6, 13463, bla bla bla
6, 44496, bla bla bla
6, 20476, bla bla bla
I have seen solutions for R, and SQL but nothing for python
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
