Reputation: 1547
I want to create a new dataframe column surv
with lts
and non_lts
labels, where for all values of the clin["OS_MONTHS"]
column in the clin
dataframe, label the value as lts
if value is <= 2*12, else label it as non_lts
.
The criteria is:
import pandas as pd
non_lts = clin[(clin["OS_MONTHS"].astype(float)<= 2*12)]
lts = clin[~clin.isin(non_lts)].dropna()
but I want it as a dataframe surv
.
My attempt:
# Survival info
def survival(clin):
if clin["OS_MONTHS"].astype(float)<= 2*12:
val = "lts"
else:
val = "non-lts"
return val
clin['SURV'] = clin.apply(survival, axis=1)
Desired output surv
surv | |
---|---|
0 | lts |
1 | non_lts |
Upvotes: 0
Views: 39