Forum Discussion

Rdog6's avatar
Rdog6
Copper Contributor
Mar 21, 2022

Fill Column with values from a row with a specific text on the left

Hello

 

I have a large dataframe and I want to create a new column with gives me the value of cell on the right side of a cell that contains a specific text.

 

The table below is an example of my table. I want to fill the last column (Caffeine) with the values that are written on the right side of the word "caffeine" anywhere in the row. The problem is that caffeine can be written in various places (here in columns concurrent medication 1 AND 2).  I have tried it with index and math, but I cannot get it to work.

 

does anyone know a solution for this?

PATIENT IDPATIENT STATUSWEIGHTDATE OF TREATMENTPATIENT TREATMENT NUMBERRESTIMULATIONCONCURRENT MEDICATION_1CONCURRENT MEDICATION_1 DOSE (MG)CONCURRENT MEDICATION_2CONCURRENT MEDICATION_2 DOSE (MG)Caffeine
875452 8002.03.22 08:4133NoCaffeine200   
875452 8009.02.22 11:4132NoPropofol20Caffeine200 

Resources