samedi 19 septembre 2020

Dealing with values that occur on the same date

How do find values that occur on the same date between two different columns in the same dataframe. Delete the values occurring in A01_CD columns and replace it with NA. And in cases where A01_CD has values, it should be moved to A01 and NA should be placed in A01. I have been trying to used duplicate () and Unique () and ifelse, but I am failing. Kindly assist.

My dataframe

    Date         A01        A01_CD
1   1966/05/07  4.870000    4.870
2   1966/05/08  4.918333    NA
3   1966/05/09  4.892000    4.860
4   1966/05/10  4.858917    NA
5   1966/05/11  4.842000    NA
211 1967/03/18  NA          5.95

Desired Outcome

    Date         A01        A01_CD
1   1966/05/07  4.870000    NA
2   1966/05/08  4.918333    NA
3   1966/05/09  4.892000    NA
4   1966/05/10  4.858917    NA
5   1966/05/11  4.842000    NA
211 1967/03/18  5.95        NA

Aucun commentaire:

Enregistrer un commentaire