mercredi 3 janvier 2018

Python Dataframe: Conditional Concatenation Based on String Value in Column

The python data frame I currently have contains two columns: "EVENT" and "NAME".

EVENT   NAME
A       DEN
B       HAU
C       TOT
D       ABC
E       DEN

I want to implement logic so that my EVENT column is as follows:

EVENT
A_DEN
B
C
D
E_DEN

I want to implement logic that says if "NAME" column contains DEN value then concatenate it to the value in "EVENT" column. Otherwise, leave value as is in "EVENT" column.

I have scoured the internet on how to do this but wasn't able to find anything specific to what I'm trying to accomplish.

Aucun commentaire:

Enregistrer un commentaire