jeudi 25 juin 2020

Taking values with atleast one specified values from another coloumn

I have this dataset

custID     documentno    quantity    producttype
1          1281261658       3        accesories
1          1281261658       3        major
1          1281261658       3        accesories
2          0105162445       2        major      
2          0105162445       2        major
3          0100848728       2        major
3          0100848728       2        acceosories
4          0106075074       1        major

So, I want to filter the dataset in a way I want documentno's with atleast one accesories in it. So I want to remove if there any document with only major in it.

custID = {1,1,1,2,2,3,3,4}
documentno = {1281261658,1281261658,1281261658,0105162445,0105162445,0100848728,0100848728,0106075074}
quantity = {3,3,3,2,2,2,2,1}
producttype = {'accesories','major','accesories','major','major','major','accesories','major'}

the final result is:

id     documentno   quantity    producttype
1      1281261658      3        accesories
1      1281261658      3        major
1      1281261658      3        accesories
3      0100848728      2        major
3      0100848728      2        accesories

I tried with if else, but I couldnt do it.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire