This question already has an answer here:
- Conditional Replace Pandas 5 answers
I have a dataframe transactions
with 2 columns source_number
and return_code
I would like to keep the string values of source number
whenever the return code
is not "successfully completed" and replace it with the string of numbers from return code
whenever it is successfully completed.
I came up with this:
if "Successfully completed" in transactions['return_code']: transactions['source_number'] = transactions['return_code'] else: transactions['source_number']
to then remove "|Successfully completed" from the new value in source number
but this does not make any modification when I run the script.
Any help is more than welcomed! Thank you
Aucun commentaire:
Enregistrer un commentaire