I have a dataframe with an ID column, and 2 other columns named "Legal Employer" and "Legacy Legal Employer" like this:
ID Legal Employer Legacy Legal Employer
1 Warehouse Warehouse 4
1 Pool Warehouse 4
1 Drive Warehouse 4
2 Warehouse
2 Drive Warehouse
3 Warehouse Drive
3 Pool
4 Drive Drive 4
4 Warehouse Drive 4
For each unique ID, I want to keep only 1 row, considering the following:
- If for that ID there is a blank (NaN) on column on "Legacy Legal Employer", keep that row and remove the others
- If for that ID there is no blank (NaN) on column on "Legacy Legal Employer", keep the first record and remove others
This would result in this dataframe:
ID Legal Employer Legacy Legal Employer
1 Warehouse Warehouse 4
2 Warehouse
3 Pool
4 Drive Drive 4
What is the best way to achive this?
Thank you!