I want to add a new column 'check' with the following condition:
- 'Suppression total' and 'Sup-SDM'.
OR
- Suppression partiel and Franc SUP - Geisi
Dataframe:
Date of event | Type | Info |
---|---|---|
2021-12-08 | Sup_EF - SUP - SDM | 2021-12-08 16:47:51.0-Suppression totale |
2021-12-15 | Modif_EF - SUP - SDM | 2021-12-08 16:47:51.0-Creation |
2021-12-31 | Sup_EF - SUP - Geisi | 2021-12-08 16:47:51.0-Suppression totale |
2021-12-17 | Modif_EF - Franc SUP - Geisi | 2021-12-17 10:50:40.0-Suppression partiel |
Desired output:
Date of event | Type | Info | Check |
---|---|---|---|
2021-12-08 | Sup_EF - SUP - SDM | 2021-12-08 16:47:51.0-Suppression total | Correct |
2021-12-15 | Modif_EF - SUP - SDM | 2021-12-08 16:47:51.0-Creation | Fail |
2021-12-31 | Sup_EF - SUP - Geisi | 2021-12-08 16:47:51.0-Suppression total | Fail |
2021-12-17 | Modif_EF - Franc SUP - Geisi | 2021-12-17 10:50:40.0-Suppression partiel | Correct |
Code:
df['check'] = np.where((df.Type.str.contains('SUP - SDM') & df.Info.str.contains('Suppression total') & (df['Date of event] in df.Info))
| (df.Type.str.contains('Franc SUP - Geisi') & (df.Info.str.contains('Suppression partiel'))&& (df['Date of event] in df.Info))),'correct','fail')
But error 'Series' objects are mutable, thus they cannot be hashed