mercredi 21 octobre 2020

New category column based on column value

I am trying to use if and ifelse statement to create a new column in my dataframe based on the values of an existing column. For example, I have a variable column which has numbers from 1 to 10000. I want to categorize them into 8 buckets (using 1250 size) in my new column. So if I have 1 in my column, I should get b1 in the new column. If I have 9999, I should get b8, etc. My if else code is failing so far.

Thanks!

Aucun commentaire:

Enregistrer un commentaire