mercredi 7 mars 2018

Python: Remove string value from row if two other columns contain 'No' string in same row

I have the following sample table below in a pandas dataframe.

Col1       Col2        Col3     Col4          Col5
                       No       4/30/2018     No
                       No       4/30/2018     No
Await AIR  7/15/2015   Yes      4/30/2018     No
Await LER  7/15/2015   No       4/30/2018     No
Await TEE  7/15/2015   No       4/30/2018     No

The logic I want to implement is as follows: If Col3 is 'No' AND Col5 is 'No' I want to remove the string in Col1 (if it is not blank already) and make it blank.

Below is my desired output table:

Col1       Col2        Col3     Col4          Col5
                       No       4/30/2018     No
                       No       4/30/2018     No
Awaiting   7/15/2015   Yes      4/30/2018     No
           7/15/2015   No       4/30/2018     No
           7/15/2015   No       4/30/2018     No

I think I have the if statement but don't know how to code the remainder of my logic:

if df_EVENT5_21['shipping_filter'] == 'No' and df_EVENT5_21['shipping_filter_2'] == 'No':
    ...

Aucun commentaire:

Enregistrer un commentaire