I have a dataframe that looks something like:
index A ... pheno
0 0.8 0
:
500000 1.4 5
where pheno is a int between 0 and 5.
I want to iterate over the rows and check the pheno column and create a new column based on the value in pheno, so if pheno is 0 then the new column class will be 1.
so:
index A ... pheno class
0 0.8 0 1
:
500000 1.4 5 3
I know how to do this using df.iterrows and if/elif but was wondering if there was a quicker way than generating 5 elif statements for each pheno value?
Just to add - in some cases my pheno column can be up to 13+ values hence why I think if/elif are inefficient.