dframe = pd.DataFrame({'Num':['38-30','38-30','21-51','24-11','34-20'],'Des':['Generates Vacuum','Pressure low','Ground Problem','Leak from Controller','Lock Unserviceable']})
In the above dataframe I want to extract specific strings from 'Des' column based on the 'Num' column. For instance, if 'Num' is equal to '38-30' then extract 'Vacuum' from 'Des' and if it doesn't have 'Vacuum', then extract 'Pressure'. There are multiple strings that I have to extract for each 'Num'.
I am trying to use re.extract('generator|vacuum',re.I) but I don't know how to include if statements as I stated above.
Aucun commentaire:
Enregistrer un commentaire