Logic I'm trying to implement:
- If 'phasename' column contains C1, C2, C4, or C18 AND 'reqmnt' column contains C
- Replace C in requirement column with value in 'phasename' column
- OTHERWISE leave 'reqmnt' column as is
Below is a sample screen shot of what I'm trying to do
Currently, I'm not able to figure out how to incorporate the AND condition in my python code. So I'm getting the results from current_column in the screen shot.
# create mapping dictionary
phasename_dictionary = {'C1':'C1', 'C2':'C2', 'C4':'C4', 'C18':'C18'}
# replace column value
df.loc[df['phasename'].isin(phasename_dictionary.keys()), 'reqmnt'] = df['phasename'].map(phasename_dictionary)
Aucun commentaire:
Enregistrer un commentaire