mardi 4 septembre 2018

Python Pandas if column id value greater

I have what i think is a simple quesiton, but I am not sure how to implement. I have the following dataframe:

ID    Value
1     100
2     250
3     300
4     400
5     600
7     800

I would like to look at 2 id's: 3 & 5 and then drop the one with the lower value. So i am assuming I would use something like the following code, but again, i am not sure how to implement,nor am i sure how to utilize the inequality to point towards the value while directing my function at a very specific pair of id's.

def ChooseGreater(x):
    if df['id'] == 3 > df['id'] ==5
        return del df['id']==5
    else:
        return del df['id']==3

Thank you!

Aucun commentaire:

Enregistrer un commentaire